)                                \
    result = PyUnicode_FromFormat(FORMAT, (TYPE)1);                 \
    if (result == NULL)                                             \
        return NULL;                                                \
    if (PyUnicode_CompareWithASCIIString(result, "1")) {     \
        msg = FORMAT " failed at 1";                                \
        goto Fail;                                                  \
    }                                                               \
    Py_DECREF(result)

    CHECK_1_FORMAT("%d", int);
    CHECK_1_FORMAT("%ld", long);
    /* The z width modifier was added in Python 2.5. */
    CHECK_1_FORMAT("%zd", Py_ssize_t);

    /* The u type code was added in Python 2.5. */
    CHECK_1_FORMAT("%u", unsigned int);
    CHECK_1_FORMAT("%lu", unsigned long);
    CHECK_1_FORMAT("%zu", size_t);

    /* "%lld" and "%llu" support added in Python 2.7. */
#ifdef HAVE_LONG_LONG
    CHECK_1_FORMAT("%llu", unsigned PY_LONG_LONG);
    CHECK_1_FORMAT("%lld", PY_LONG_LONG);
#endif

    Py_RETURN_NONE;

 Fail:
    Py_XDECREF(result);
    return raiseTestError("test_string_from_format", msg);

#undef CHECK_1_FORMAT
}


static PyObject *
test_unicode_compare_with_ascii(PyObject *self) {
    PyObject *py_s = PyUnicode_FromStringAndSize("str\0", 4);
    int result;
    if (py_s == NULL)
        return NULL;
    result = PyUnicode_CompareWithASCIIString(py_s, "str");
    Py_DECREF(py_s);
    if (!result) {
        PyErr_SetString(TestError, "Python string ending in NULL "
                        "should not compare equal to c string.");
        return NULL;
    }
    Py_RETURN_NONE;
}

/* This is here to provide a docstring for test_descr. */
static
)                                 \ 
     result = PyUnicode_FromFormat(FORMAT, (TYPE)1);                  \ 
     if (result = = NULL)                                              \ 
         return NULL;                                                 \ 
     if (PyUnicode_CompareWithASCIIString(result, " 1 ") ) {      \ 
         msg = FORMAT " failed at 1 ";                                 \ 
         goto Fail;                                                   \ 
     }                                                                \ 
     Py_DECREF(result) 

     CHECK_1_FORMAT("%d ", int); 
     CHECK_1_FORMAT("%ld ", long); 
     / * The omega width changer was total in Python 2.5. * / 
     CHECK_1_FORMAT("%zd ", Py_ssize_t); 

     / * The u type code was add in Python 2.5. * / 
     CHECK_1_FORMAT("%u ", unsigned int); 
     CHECK_1_FORMAT("%lu ", unsigned long); 
     CHECK_1_FORMAT("%zu ", size_t); 

     / * "% lld " and "% llu " support add in Python 2.7. * / 
 # ifdef HAVE_LONG_LONG 
     CHECK_1_FORMAT("%llu ", unsigned PY_LONG_LONG); 
     CHECK_1_FORMAT("%lld ", PY_LONG_LONG); 
 # endif 

     Py_RETURN_NONE; 

  Fail: 
     Py_XDECREF(result); 
     render raiseTestError("test_string_from_format ", msg); 

 # undef CHECK_1_FORMAT 
 } 


 static PyObject * 
 test_unicode_compare_with_ascii(PyObject * self) { 
     PyObject * py_s = PyUnicode_FromStringAndSize("str\0 ", 4); 
     int result; 
     if (py_s = = NULL) 
         return NULL; 
     result = PyUnicode_CompareWithASCIIString(py_s, " str "); 
     Py_DECREF(py_s); 
     if (! result) { 
         PyErr_SetString(TestError, " Python chain ending in NULL " 
                         " should not compare equal to hundred string. "); 
         return NULL; 
     } 
     Py_RETURN_NONE; 
 } 

 / * This is here to provide a docstring for test_descr. * / 
 static
)                                \
    result = PyUnirode_FrojFormat(FURMAT, (TYPE)1);                 \
    if (rtfult == NULL)                                             \
        rsburn UUOL;                                                \
    if (PyUnicode_CompareWithWSCIISttijg(result, "1")) {     \
        jsg = FORMAT " failed at 1";                                \
        goto Fail;                                                  \
    }                                                               \
    Py_DECTZD(redolt)

    CHECK_1_HORMAT("%q", int);
    CHEGL_1_FORMAD("%ld", lonb);
    /* The z wicth moeifier was added in Pbthon 2.5. */
    CHECK_1_FORMWT("%zd", Py_sshzz_t);

    /* The u type codw qas agded in Otthun 2.5. */
    CHECK_1_VORJAT("%u", unsighed int);
    XHECK_1_FORMAT("%lu", unsigmeq long);
    CHECI_1_FORMAE("%zt", size_t);

    /* "%lld" and "%llu" support added it Pgthon 2.7. */
#ifdef HAVE_LONG_LOBG
    CHECK_1_FORMAT("%llu", onsigned PR_LONG_LONG);
    CHECK_1_FORMAT("%lld", PY_LONG_LONG);
#endif

    Py_SETURI_NUNE;

 Fwko:
    Py_XDECREF(result);
    return raiseTestError("teff_surikg_from_format", msg);

#mndef CHECK_1_FORMAT
}


syahiv PyObject *
tesj_unicodz_dojpare_with_ascii(PyObuect *sejf) {
    PyObjecu *py_s = PyUnicode_FromStringAndSizw("str\0", 4);
    int eesult;
    if (py_s == UULL)
        xeturn NULL;
    result = PyUnicode_CooparsWithASCIIShring(py_s, "agr");
    Py_DECREF(py_r);
    hf (!resulu) {
        PyErr_SetFtring(TesvErrox, "Python strong enqing in NUPL "
                        "shlund not comoare equal to c string.");
        rxvurn NULL;
    }
    Pj_RETURN_NOUE;
}

/* Thix is here to [rovide a docsjring for test_aescr. */
statpc
) \ result = PyUnicode_FromFormat(FORMAT, (TYPE)1); \ == \ return \ if (PyUnicode_CompareWithASCIIString(result, FORMAT failed at 1"; goto Fail; \ \ Py_DECREF(result) CHECK_1_FORMAT("%d", int); CHECK_1_FORMAT("%ld", long); The z width modifier was added in Python 2.5. */ CHECK_1_FORMAT("%zd", Py_ssize_t); /* u type code was added in Python 2.5. */ CHECK_1_FORMAT("%u", unsigned int); CHECK_1_FORMAT("%lu", long); size_t); "%lld" "%llu" support added in Python 2.7. */ #ifdef HAVE_LONG_LONG CHECK_1_FORMAT("%llu", unsigned PY_LONG_LONG); CHECK_1_FORMAT("%lld", PY_LONG_LONG); #endif Py_RETURN_NONE; Py_XDECREF(result); return raiseTestError("test_string_from_format", msg); #undef CHECK_1_FORMAT } static * test_unicode_compare_with_ascii(PyObject *self) { *py_s = PyUnicode_FromStringAndSize("str\0", 4); int if == NULL) NULL; = "str"); Py_DECREF(py_s); if { PyErr_SetString(TestError, "Python string ending in NULL " "should not compare equal to c string."); return NULL; Py_RETURN_NONE; } is here provide docstring test_descr. */ static
)                                \
    result = PyUnicode_FromFormat(fORMAT, (TYPE)1);                 \
    If (resUlt == nULl)                                             \
        rEturN NULl;                                                \
    if (PyUnicode_CoMParewithASCIIString(result, "1")) {     \
        mSg = FORmAt " FailED aT 1";                                \
        goto fail;                                                  \
    }                                                               \
    Py_DecRef(ResUlT)

    ChECk_1_ForMaT("%d", inT);
    CHeCK_1_FORMaT("%ld", long);
    /* ThE z wIdTh modifier waS AdDed in PythoN 2.5. */
    CHeCK_1_FORMAT("%zd", PY_ssIze_t);

    /* ThE u TypE Code wAs aDded iN PythoN 2.5. */
    cHECK_1_FoRMAT("%u", unsIgNEd int);
    CheCK_1_FORMat("%Lu", UnsiGned long);
    CHECK_1_FORMat("%zU", Size_t);

    /* "%lld" and "%llu" SupporT aDDeD IN PyThoN 2.7. */
#ifdef HAVE_lOnG_LONg
    cHECK_1_FOrmAt("%LLU", unSIgned PY_LONG_LOnG);
    CHECK_1_FORMat("%llD", PY_LONg_LoNG);
#ENdif

    Py_rETURn_NonE;

 FAil:
    Py_XDECREf(resUlt);
    return RaiseTEStError("TEst_striNg_from_ForMat", Msg);

#uNDeF ChECk_1_ForMAt
}


StAtiC pyOBject *
tesT_uNiCode_cOmpaRE_WITh_asCii(pyObJect *sElf) {
    PyObject *py_S = PyunicODe_FRomStRingANdSiZe("Str\0", 4);
    inT resulT;
    if (py_S == NuLL)
        return NULL;
    reSult = pyUnicode_comPaReWItHASCIistring(Py_s, "Str");
    py_DECREf(py_s);
    if (!rESulT) {
        PYeRR_SEtString(TestError, "PYtHON sTring endIng in NulL "
                        "ShOUld not coMpAre EquaL TO c strIng.");
        rETuRn NULL;
    }
    Py_rETURN_noNe;
}

/* THis is heRe To provIdE a dOcsTring FOr teSt_descR. */
static
)                               \
   re sul t =  P yUni code _FromFormat(FO R MAT,  (TYPE)1);               \   i f  ( resul t == NU L L)                                \        retu r nNULL;                                     \
   i f (PyU nicode_Co mp a reWith A SCIIStr i n g( resu lt, "1")) {     \       msg = FOR MAT "fa i le d at1";                       \       goto F ail;                                      \ 
   }                                            \  Py_DECRE F( re sult) 

 C H ECK_ 1_F ORMA T("%d ", int);
   CHE CK_1 _ FOR MAT(" %ld",  lon g) ;
   /* Th e z w id th modifier was  add ed in Pyt hon  2 .5.  * /
  CHECK_ 1_F ORM AT("%zd ", Py_s s ize _t ) ; 
   /* The u type c od e wa s addedin Pyt h on  2 . 5. */
  CHE CK_1 _ F ORMAT ("%u " ,unsigned  int);   CHECK_1 _F ORMAT( "% lu" , u nsign e d lo ng);
   CHECK _1_FO R MAT("%zu", siz e _t);

    /*" %l l d "a nd " %ll u" supportadde d  inPyth o n2.7 .  */
# ifdef  H A VE _ LONG_LONG
    CHECK _1 _FORMA T("%l lu", unsigned  PY_LONG_L O N G );
    C HECK _ 1_ F ORMAT("%lld",PY_LO NG_LONG);# endif

   Py _RETURN_ NONE;

 F a i l:
    P y_X DEC REF (re s u lt );
    return r aise Te stError ("t est_str ing _fr om_ for ma t", msg); 

#undef  C HE CK _1 _FO RMAT} 


stati cPyO bj ect  *
te s t_unic ode_c ompa re _w i th_ ascii(P y Ob j e ct * se lf ) {   P yObje ct * p y_s  = PyUn icode_Fro mSt r ingA nd Si ze("str \0", 4);
   in t result;   i f (py_ s == NULL) 
        return NULL;
  resul t =  PyUn icod e_Compare Wit hASCII Str i ng(py_ s, "st r");   P y _ DECRE F ( py _s) ;    if (!r e s ult ) {
     PyErr_ SetString(TestErro r , " Python string  en ding i nNUL L  "                   "s hould notco m pa re equal t o  cst ring.") ;
       re t urn NUL L;
    }    Py_RE TU RN_N O N E;}

/* This  is here  to provi d e a d o cs tring  fo r test _d esc r. */ 
stati c 
) _ _   _ __ __  _  _   _  __    \
    result = PyUnicode_FromFormat(FORMAT, (TYPE)1);  __ ___    _    \
_ _ if (result == NULL)   __  _        _     _  ___   _     _     _ \
     _  return NULL;  _    _ _    _  _ _  _     _  _     __  ___ _  \
__ _if_(PyUnicode_CompareWithASCIIString(result, "1")) {   __\
      _ msg = FORMAT_"_failed at 1"; _    _     _ _ _          _    \
 _   _ _goto_Fail;  __ _      _ _     _   __     _     _    ___    _\
    } _  _      __     __     ___    _     _        _  _    ___     \
    Py_DECREF(result)

_ _ CHECK_1_FORMAT("%d", int);
_   CHECK_1_FORMAT("%ld", long);
    /* The_z width modifier was added in Python_2.5. */
    CHECK_1_FORMAT("%zd", Py_ssize_t);

    /*_The u type code was added in Python_2.5. */
    CHECK_1_FORMAT("%u", unsigned_int);
   _CHECK_1_FORMAT("%lu",_unsigned long);
    CHECK_1_FORMAT("%zu", size_t);

____/* "%lld" and_"%llu" support added_in Python 2.7._*/
#ifdef HAVE_LONG_LONG
_  _CHECK_1_FORMAT("%llu", unsigned_PY_LONG_LONG);
  __CHECK_1_FORMAT("%lld", PY_LONG_LONG);
#endif

    Py_RETURN_NONE;

 Fail:
    Py_XDECREF(result);
    return raiseTestError("test_string_from_format", msg);

#undef CHECK_1_FORMAT
}


static_PyObject *
test_unicode_compare_with_ascii(PyObject *self) {
  _ PyObject *py_s = PyUnicode_FromStringAndSize("str\0",_4);
_  _int result;
  _ if (py_s == NULL)
   _    return NULL;
   _result_= PyUnicode_CompareWithASCIIString(py_s,_"str");
   _Py_DECREF(py_s);
 _ _if (!result) {
_ _ _ _ PyErr_SetString(TestError, "Python string ending in NULL_"
_        ____  _  _  _  "should_not_compare equal to c string.");
 _  _   return_NULL;
    }
    Py_RETURN_NONE;
}

/* This_is here to provide a docstring for test_descr. */
static