2012-05-31 04:17:08 +02:00
|
|
|
#include <CuTest.h>
|
2011-02-24 08:23:32 +01:00
|
|
|
#include "base36.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void test_atoi36(CuTest * tc)
|
|
|
|
{
|
2010-08-08 10:06:34 +02:00
|
|
|
CuAssertIntEquals(tc, 0, atoi36("0"));
|
|
|
|
CuAssertIntEquals(tc, 666, atoi36("ii"));
|
|
|
|
CuAssertIntEquals(tc, -10, atoi36("-a"));
|
|
|
|
CuAssertIntEquals(tc, -1, atoi36("-1"));
|
|
|
|
CuAssertIntEquals(tc, -10, atoi("-10"));
|
|
|
|
CuAssertIntEquals(tc, -10, atoi("-10"));
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
static void test_itoa36(CuTest * tc)
|
|
|
|
{
|
2010-08-08 10:06:34 +02:00
|
|
|
CuAssertStrEquals(tc, itoa36(0), "0");
|
|
|
|
CuAssertStrEquals(tc, itoa10(INT_MAX), "2147483647");
|
2014-09-29 18:32:12 +02:00
|
|
|
CuAssertStrEquals(tc, itoab(INT_MAX, 8), "17777777777");
|
|
|
|
CuAssertStrEquals(tc, itoab(INT_MAX, 4), "1333333333333333");
|
2010-08-08 10:06:34 +02:00
|
|
|
CuAssertStrEquals(tc, itoab(-1, 5), "-1");
|
|
|
|
CuAssertStrEquals(tc, itoa36(-1), "-1");
|
|
|
|
CuAssertStrEquals(tc, itoa36(-10), "-a");
|
|
|
|
CuAssertStrEquals(tc, itoa36(666), "ii");
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
CuSuite *get_base36_suite(void)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2011-03-07 08:02:35 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
2010-08-08 10:06:34 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_itoa36);
|
|
|
|
SUITE_ADD_TEST(suite, test_atoi36);
|
|
|
|
return suite;
|
|
|
|
}
|