int main()
{
    /* How many integer test items should be created. */
    static const size_t s_cTestCount = 1000;

    RTTEST hTest;
    RTEXITCODE rcExit = RTTestInitAndCreate("tstIprtList", &hTest);
    if (rcExit)
        return rcExit;
    RTTestBanner(hTest);

    /* Some host info. */
    RTTestIPrintf(RTTESTLVL_ALWAYS, "sizeof(void*)=%d", sizeof(void*));

    /*
     * The tests.
     */

    /*
     * Native types.
     */
    uint8_t au8TestInts[s_cTestCount];
    for (size_t i = 0; i < RT_ELEMENTS(au8TestInts); ++i)
        au8TestInts[i] = (uint8_t)RTRandU32Ex(1, UINT8_MAX);
    test1<RTCList,   uint8_t, uint8_t, uint8_t>("ST: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));
    test1<RTCMTList, uint8_t, uint8_t, uint8_t>("MT: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));

    uint16_t au16TestInts[s_cTestCount];
    for (size_t i = 0; i < RT_ELEMENTS(au16TestInts); ++i)
        au16TestInts[i] = (uint16_t)RTRandU32Ex(1, UINT16_MAX);
    test1<RTCList,   uint16_t, uint16_t, uint16_t>("ST: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));
    test1<RTCMTList, uint16_t, uint16_t, uint16_t>("MT: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));

    uint32_t au32TestInts[s_cTestCount];
    for (size_t i = 0; i < RT_ELEMENTS(au32TestInts); ++i)
        au32TestInts[i] = RTRandU32Ex(1, UINT32_MAX);
    test1<RTCList,   uint32_t, uint32_t, uint32_t>("ST: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));
    test1<RTCMTList, uint32_t, uint32_t, uint32_t>("MT: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));

    /*
     * Specialized type.
     */
    uint64_t au64TestInts[s_cTestCount];
    for (size_t i = 0; i < RT_ELEMENTS(au64TestInts); ++i)
        au64TestInts[i] = RTRandU64Ex(1, UINT64_MAX);
    test1<RTCList,   uint64_t, uint64_t, uint64_t>("ST: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));
    test1<RTCMTList, uint64_t, uint64_t, uint64_t>("MT: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));

    /*
     * Big size type (translate to internal pointer list).
     */
    test1<RTCList,   RTCString, RTCString *, const char *>("ST: Class type", g_apszTestStrings, RT_ELEMENTS(g_apszTestStrings));
    test1<RTCMTList, RTCString, RTCString *, const char *>("MT: Class type", g_apszTestStrings, RT_ELEMENTS(g_apszTestStrings));

    /*
     * Multi-threading test.
     */
    test2();

    /*
     * Summary.
     */
    return RTTestSummaryAndDestroy(hTest);
}
int main()
{
    test1();
    test2();
}
int _tmain(int argc, _TCHAR* argv[])
{
	test1();
	test2();
}
int main()
{
    /*
     * Init the runtime and stuff.
     */
    RTTEST hTest;
    int rc = RTTestInitAndCreate("tstRTBitOperations", &hTest);
    if (rc)
        return rc;
    RTTestBanner(hTest);

    int i;
    int j;
    int k;

    /*
     * Tests
     */
    struct TestMap
    {
        uint32_t au32[4];
    };
#if 0
    struct TestMap sTest;
    struct TestMap *p = &sTest;
#else
    struct TestMap *p = (struct TestMap *)RTTestGuardedAllocTail(hTest, sizeof(*p));
#endif
#define DUMP()          RTTestPrintf(hTest, RTTESTLVL_INFO, "au32={%08x,%08x,%08x,%08x}", p->au32[0], p->au32[1], p->au32[2], p->au32[3])
#define CHECK(expr)     do { if (!(expr)) { RTTestFailed(hTest, "line %d: %s", __LINE__, #expr); DUMP(); } CHECK_GUARD(s); } while (0)
#define CHECK_BIT(expr,  b1)            do { if (!(expr)) { RTTestFailed(hTest, "line %d, b1=%d: %s", __LINE__, b1, #expr); } CHECK_GUARD(s); } while (0)
#define CHECK_BIT2(expr, b1, b2)        do { if (!(expr)) { RTTestFailed(hTest, "line %d, b1=%d b2=%d: %s", __LINE__, b1, b2, #expr); } CHECK_GUARD(s); } while (0)
#define CHECK_BIT3(expr, b1, b2, b3)    do { if (!(expr)) { RTTestFailed(hTest, "line %d, b1=%d b2=%d b3=%d: %s", __LINE__, b1, b2, b3, #expr); } CHECK_GUARD(s); } while (0)

#define GUARD_MAP(p)    do {  } while (0)
#define CHECK_GUARD(p)  do {  } while (0)
#define MAP_CLEAR(p)    do { RT_ZERO(*(p)); GUARD_MAP(p); } while (0)
#define MAP_SET(p)      do { memset(p, 0xff, sizeof(*(p))); GUARD_MAP(p); } while (0)

    /* self check. */
    MAP_CLEAR(p);
    CHECK_GUARD(p);

    /* set */
    MAP_CLEAR(p);
    ASMBitSet(&p->au32[0], 0);
    ASMBitSet(&p->au32[0], 31);
    ASMBitSet(&p->au32[0], 65);
    CHECK(p->au32[0] == 0x80000001U);
    CHECK(p->au32[2] == 0x00000002U);
    CHECK(ASMBitTestAndSet(&p->au32[0], 0)   && p->au32[0] == 0x80000001U);
    CHECK(!ASMBitTestAndSet(&p->au32[0], 16) && p->au32[0] == 0x80010001U);
    CHECK(ASMBitTestAndSet(&p->au32[0], 16)  && p->au32[0] == 0x80010001U);
    CHECK(!ASMBitTestAndSet(&p->au32[0], 80) && p->au32[2] == 0x00010002U);

    MAP_CLEAR(p);
    ASMAtomicBitSet(&p->au32[0], 0);
    ASMAtomicBitSet(&p->au32[0], 30);
    ASMAtomicBitSet(&p->au32[0], 64);
    CHECK(p->au32[0] == 0x40000001U);
    CHECK(p->au32[2] == 0x00000001U);
    CHECK(ASMAtomicBitTestAndSet(&p->au32[0], 0)   && p->au32[0] == 0x40000001U);
    CHECK(!ASMAtomicBitTestAndSet(&p->au32[0], 16) && p->au32[0] == 0x40010001U);
    CHECK(ASMAtomicBitTestAndSet(&p->au32[0], 16)  && p->au32[0] == 0x40010001U);
    CHECK(!ASMAtomicBitTestAndSet(&p->au32[0], 80) && p->au32[2] == 0x00010001U);

    /* clear */
    MAP_SET(p);
    ASMBitClear(&p->au32[0], 0);
    ASMBitClear(&p->au32[0], 31);
    ASMBitClear(&p->au32[0], 65);
    CHECK(p->au32[0] == ~0x80000001U);
    CHECK(p->au32[2] == ~0x00000002U);
    CHECK(!ASMBitTestAndClear(&p->au32[0], 0)   && p->au32[0] == ~0x80000001U);
    CHECK(ASMBitTestAndClear(&p->au32[0], 16)   && p->au32[0] == ~0x80010001U);
    CHECK(!ASMBitTestAndClear(&p->au32[0], 16)  && p->au32[0] == ~0x80010001U);
    CHECK(ASMBitTestAndClear(&p->au32[0], 80)   && p->au32[2] == ~0x00010002U);

    MAP_SET(p);
    ASMAtomicBitClear(&p->au32[0], 0);
    ASMAtomicBitClear(&p->au32[0], 30);
    ASMAtomicBitClear(&p->au32[0], 64);
    CHECK(p->au32[0] == ~0x40000001U);
    CHECK(p->au32[2] == ~0x00000001U);
    CHECK(!ASMAtomicBitTestAndClear(&p->au32[0], 0)   && p->au32[0] == ~0x40000001U);
    CHECK(ASMAtomicBitTestAndClear(&p->au32[0], 16)   && p->au32[0] == ~0x40010001U);
    CHECK(!ASMAtomicBitTestAndClear(&p->au32[0], 16)  && p->au32[0] == ~0x40010001U);
    CHECK(ASMAtomicBitTestAndClear(&p->au32[0], 80)   && p->au32[2] == ~0x00010001U);

    /* toggle */
    MAP_SET(p);
    ASMBitToggle(&p->au32[0], 0);
    ASMBitToggle(&p->au32[0], 31);
    ASMBitToggle(&p->au32[0], 65);
    ASMBitToggle(&p->au32[0], 47);
    ASMBitToggle(&p->au32[0], 47);
    CHECK(p->au32[0] == ~0x80000001U);
    CHECK(p->au32[2] == ~0x00000002U);
    CHECK(!ASMBitTestAndToggle(&p->au32[0], 0)   && p->au32[0] == ~0x80000000U);
    CHECK(ASMBitTestAndToggle(&p->au32[0], 0)    && p->au32[0] == ~0x80000001U);
    CHECK(ASMBitTestAndToggle(&p->au32[0], 16)   && p->au32[0] == ~0x80010001U);
    CHECK(!ASMBitTestAndToggle(&p->au32[0], 16)  && p->au32[0] == ~0x80000001U);
    CHECK(ASMBitTestAndToggle(&p->au32[0], 80)   && p->au32[2] == ~0x00010002U);

    MAP_SET(p);
    ASMAtomicBitToggle(&p->au32[0], 0);
    ASMAtomicBitToggle(&p->au32[0], 30);
    ASMAtomicBitToggle(&p->au32[0], 64);
    ASMAtomicBitToggle(&p->au32[0], 47);
    ASMAtomicBitToggle(&p->au32[0], 47);
    CHECK(p->au32[0] == ~0x40000001U);
    CHECK(p->au32[2] == ~0x00000001U);
    CHECK(!ASMAtomicBitTestAndToggle(&p->au32[0], 0)   && p->au32[0] == ~0x40000000U);
    CHECK(ASMAtomicBitTestAndToggle(&p->au32[0], 0)    && p->au32[0] == ~0x40000001U);
    CHECK(ASMAtomicBitTestAndToggle(&p->au32[0], 16)   && p->au32[0] == ~0x40010001U);
    CHECK(!ASMAtomicBitTestAndToggle(&p->au32[0], 16)  && p->au32[0] == ~0x40000001U);
    CHECK(ASMAtomicBitTestAndToggle(&p->au32[0], 80)   && p->au32[2] == ~0x00010001U);

    /* test bit. */
    for (i = 0; i < 128; i++)
    {
        MAP_SET(p);
        CHECK_BIT(ASMBitTest(&p->au32[0], i), i);
        ASMBitToggle(&p->au32[0], i);
        CHECK_BIT(!ASMBitTest(&p->au32[0], i), i);
        CHECK_BIT(!ASMBitTestAndToggle(&p->au32[0], i), i);
        CHECK_BIT(ASMBitTest(&p->au32[0], i), i);
        CHECK_BIT(ASMBitTestAndToggle(&p->au32[0], i), i);
        CHECK_BIT(!ASMBitTest(&p->au32[0], i), i);

        MAP_SET(p);
        CHECK_BIT(ASMBitTest(&p->au32[0], i), i);
        ASMAtomicBitToggle(&p->au32[0], i);
        CHECK_BIT(!ASMBitTest(&p->au32[0], i), i);
        CHECK_BIT(!ASMAtomicBitTestAndToggle(&p->au32[0], i), i);
        CHECK_BIT(ASMBitTest(&p->au32[0], i), i);
        CHECK_BIT(ASMAtomicBitTestAndToggle(&p->au32[0], i), i);
        CHECK_BIT(!ASMBitTest(&p->au32[0], i), i);
    }

    /* bit searching */
    MAP_SET(p);
    CHECK(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == -1);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 0);

    ASMBitClear(&p->au32[0], 1);
    CHECK(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == 1);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 0);

    MAP_SET(p);
    ASMBitClear(&p->au32[0], 95);
    CHECK(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == 95);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 0);

    MAP_SET(p);
    ASMBitClear(&p->au32[0], 127);
    CHECK(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == 127);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 0);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 0) == 1);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 1) == 2);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 2) == 3);


    MAP_SET(p);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, 0) == -1);
    ASMBitClear(&p->au32[0], 32);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, 32) == -1);
    ASMBitClear(&p->au32[0], 88);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8,  57) ==  88);

    MAP_SET(p);
    ASMBitClear(&p->au32[0], 31);
    ASMBitClear(&p->au32[0], 57);
    ASMBitClear(&p->au32[0], 88);
    ASMBitClear(&p->au32[0], 101);
    ASMBitClear(&p->au32[0], 126);
    ASMBitClear(&p->au32[0], 127);
    CHECK(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == 31);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8,  31) ==  57);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8,  57) ==  88);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8,  88) == 101);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, 101) == 126);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, 126) == 127);
    CHECK(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, 127) == -1);

    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 29) == 30);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 30) == 32);

    MAP_CLEAR(p);
    for (i = 1; i < 128; i++)
        CHECK_BIT(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, i - 1) == i, i);
    for (i = 0; i < 128; i++)
    {
        MAP_SET(p);
        ASMBitClear(&p->au32[0], i);
        CHECK_BIT(ASMBitFirstClear(&p->au32[0], sizeof(p->au32) * 8) == i, i);
        for (j = 0; j < i; j++)
            CHECK_BIT(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, j) == i, i);
        for (j = i; j < 128; j++)
            CHECK_BIT(ASMBitNextClear(&p->au32[0], sizeof(p->au32) * 8, j) == -1, i);
    }

    /* clear range. */
    MAP_SET(p);
    ASMBitClearRange(&p->au32, 0, 128);
    CHECK(!p->au32[0] && !p->au32[1] && !p->au32[2] && !p->au32[3]);
    for (i = 0; i < 128; i++)
    {
        for (j = i + 1; j <= 128; j++)
        {
            MAP_SET(p);
            ASMBitClearRange(&p->au32, i, j);
            for (k = 0; k < i; k++)
                CHECK_BIT3(ASMBitTest(&p->au32[0], k), i, j, k);
            for (k = i; k < j; k++)
                CHECK_BIT3(!ASMBitTest(&p->au32[0], k), i, j, k);
            for (k = j; k < 128; k++)
                CHECK_BIT3(ASMBitTest(&p->au32[0], k), i, j, k);
        }
    }

    /* searching for set bits. */
    MAP_CLEAR(p);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == -1);

    ASMBitSet(&p->au32[0], 65);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 65);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 65) == -1);
    for (i = 0; i < 65; i++)
        CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, i) == 65);
    for (i = 65; i < 128; i++)
        CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, i) == -1);

    ASMBitSet(&p->au32[0], 17);
    CHECK(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == 17);
    CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, 17) == 65);
    for (i = 0; i < 16; i++)
        CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, i) == 17);
    for (i = 17; i < 65; i++)
        CHECK(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, i) == 65);

    MAP_SET(p);
    for (i = 1; i < 128; i++)
        CHECK_BIT(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, i - 1) == i, i);
    for (i = 0; i < 128; i++)
    {
        MAP_CLEAR(p);
        ASMBitSet(&p->au32[0], i);
        CHECK_BIT(ASMBitFirstSet(&p->au32[0], sizeof(p->au32) * 8) == i, i);
        for (j = 0; j < i; j++)
            CHECK_BIT(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, j) == i, i);
        for (j = i; j < 128; j++)
            CHECK_BIT(ASMBitNextSet(&p->au32[0], sizeof(p->au32) * 8, j) == -1, i);
    }


    CHECK(ASMBitLastSetU32(0) == 0);
    CHECK(ASMBitLastSetU32(1) == 1);
    CHECK(ASMBitLastSetU32(0x80000000) == 32);
    CHECK(ASMBitLastSetU32(0xffffffff) == 32);
    CHECK(ASMBitLastSetU32(RT_BIT(23) | RT_BIT(11)) == 24);
    for (i = 0; i < 32; i++)
        CHECK(ASMBitLastSetU32(1 << i) == (unsigned)i + 1);

    CHECK(ASMBitFirstSetU32(0) == 0);
    CHECK(ASMBitFirstSetU32(1) == 1);
    CHECK(ASMBitFirstSetU32(0x80000000) == 32);
    CHECK(ASMBitFirstSetU32(0xffffffff) == 1);
    CHECK(ASMBitFirstSetU32(RT_BIT(23) | RT_BIT(11)) == 12);
    for (i = 0; i < 32; i++)
        CHECK(ASMBitFirstSetU32(1 << i) == (unsigned)i + 1);

    /*
     * Special tests.
     */
    test2(hTest);

    /*
     * Summary
     */
    return RTTestSummaryAndDestroy(hTest);
}
Exemple #5
0
int main() {
    std::cout << "h";
    test();
    std::cout << test2() << '\n';
}
Exemple #6
0
int main()
{
  test1 ();
  test2 ();
  return 0;
}
Exemple #7
0
int main(void)
{
    test1();
    test2();
}
Exemple #8
0
int main()
{
    char line[256];
    char args[4][64];

    /* It mainly calls ComputerThink(maxdepth) to calculate to desired ply */
    char s[256];
    int from;
    int dest;
    int i;

    hashRndInit();
    startgame ();

    maxDepth = 6;		/* Max depth to search */
    MOVE moveBuf[200];
    MOVE theBest;
    int movecnt;

    /* Belka */
    puts (" \n Kitteneitor version June 5th 2013 by Emilio Diaz \n =================================================\n\n");
    puts (" Help overview:");
    puts (" making a move: e.g. e2e4, c7c5, a7a8q, e1g1 etc.");
    puts (" d ............ displaying current board");
    puts (" on ........... forcing the engine to move");
    puts (" sd <n> ....... setting depth to <n> plies");
    puts (" undo ......... taking back last move (ply)");
    puts (" quit ......... quit console application \n\n");
    /* Belka */

    side = WHITE;
    computerSide = BLACK;	/* Human is white side */

    hdp = 0;			/* Current move order */
    for (;;)
    {
        fflush (stdout);
        if (side == computerSide)
        {
            /* Computer's turn */
            theBest = ComputerThink (maxDepth);

            if (theBest.type_of_move > 8)
                printf ("type of move the best %d \n", theBest.type_of_move);

            makeMove (theBest);

            /* Just the move without pawn crown */
            printf("move %c%d%c%d",
                   'a' + COL(theBest.from),
                   8 - ROW(theBest.from),
                   'a' + COL(theBest.dest),
                   8 - ROW(theBest.dest));
            /* Check whether it's a crown */
            switch (theBest.type_of_move)
            {
               case MOVE_TYPE_PROMOTION_TO_QUEEN:
                  printf("q\n");
                  break;
               case MOVE_TYPE_PROMOTION_TO_ROOK:
                  printf("r\n");
                  break;
               case MOVE_TYPE_PROMOTION_TO_BISHOP:
                  printf("b\n");
                  break;
               case MOVE_TYPE_PROMOTION_TO_KNIGHT:
                  printf("n\n");
                  break;
               default:
                  printf("\n");
            }   /* end switch */

            printBoard ();
            printf ("Castle rights: %d\n", castle);
            fflush (stdout);
            continue;
        }

        printf ("k> ");

        /* Get user input */
        if (!fgets (line, 256, stdin))
            return 0;
        if (line[0] == '\n')
            continue;
        sscanf (line, "%s", s);

//        if (scanf ("%s", s) == EOF)	/* Shut down the program */
//            return 0;

        if (!strcmp (s, "d"))
        {
            printBoard ();
            continue;
        }
        if (!strcmp (s, "test1"))
        {
            test1 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test2"))
        {
            test2 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test3"))
        {
            test3 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test4"))
        {
            test4 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test5"))
        {
            test5 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test6"))
        {
            test6 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test7"))
        {
            test7 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test8"))
        {
            test8 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test9"))
        {
            test9 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test10"))
        {
            test10 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test11"))
        {
            test11 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test12"))
        {
            test12 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test13"))
        {
            test13 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "test14"))
        {
            test14 ();
            printBoard();
            continue;
        }
        if (!strcmp (s, "testMoveGen")) //Belka: McKenzie test position
        {
            testMoveGen();
            printBoard();
            continue;
        }
        if (!strcmp (s, "testEvalSym")) //Belka: McKenzie test position
        {
            testEvalSym();
            continue;
        }
        if (!strcmp (s, "countNodes"))
        {
            countNodes();
            continue;
        }
        if (!strcmp (s, "testWhitePassedPawns"))
        {
            testWhitePassedPawns ();
            continue;
        }
        if (!strcmp (s, "testBlackPassedPawns"))
        {
            testBlackPassedPawns ();
            continue;
        }
        if (!strcmp (s, "testWhiteDoubledPawns"))
        {
            testWhiteDoubledPawns ();
            continue;
        }
        if (!strcmp (s, "testBlackDoubledPawns"))
        {
            testBlackDoubledPawns ();
            continue;
        }
        if (!strcmp (s, "testIsIsolatedPawnWhite"))
        {
            testIsIsolatedPawnWhite ();
            continue;
        }
        if (!strcmp (s, "testIsIsolatedPawnBlack"))
        {
            testIsIsolatedPawnBlack ();
            continue;
        }
        if (!strcmp (s, "showPawnsInfo"))
        {
            showPawnsInfo ();
            continue;
        }
        if (!strcmp (s, "testisSqProtectedByAPawn"))
        {
             testisSqProtectedByAPawn();
            continue;
        }
//        if (!strcmp (s, "testIsSqProtectedByAKnight"))
//        {
//             testIsSqProtectedByAKnight();
//            continue;
//        }
//        if (!strcmp (s, "testIsSqProtectedByABishop"))
//        {
//             testIsSqProtectedByABishop();
//            continue;
//        }
        if (!strcmp (s, "testOpenCols"))
        {
             testOpenCols();
            continue;
        }
        if (!strcmp (s, "undo"))
        {
            takeBack ();
            printBoard ();
            computerSide = (WHITE + BLACK) - computerSide;
            continue;
        }
        if (!strcmp(s,"setboard"))
        {
            strcpy(fenBuf, "");
            sscanf(line, "setboard %s %s %s %s", args[0],args[1],args[2],args[3]);
            strcat(fenBuf, args[0]);
            strcat(fenBuf, args[1]);
            strcat(fenBuf, args[2]);
            strcat(fenBuf, args[3]);
            setBoard(fenBuf);
            continue;
        }
        if (!strcmp (s, "xboard"))
        {
            xboard ();
            return 0;
        }
        if (!strcmp (s, "on"))
        {
            computerSide = side;
            continue;
        }
        if (!strcmp (s, "pass"))
        {
            side = (WHITE + BLACK) - side;
            computerSide = (WHITE + BLACK) - side;
            continue;
        }
        if (!strcmp (s, "sd"))
        {
            sscanf (line, "sd %d", &maxDepth);
            continue;
        }

//        if (!strcmp (s, "fen"))
//        {
//            strcpy (fenstring, "");

//            sscanf (linea, "fen %s %s %s %s", args[0], args[1], args[2],
//                    args[3]);

//            strcat (fenstring, args[0]);
//            strcat (fenstring, args[1]);
//            strcat (fenstring, args[2]);
//            strcat (fenstring, args[3]);

//            fen (fenstring);
//        }

        if (!strcmp (s, "perft"))
        {
            sscanf (line, "perft %d", &maxDepth);
            clock_t start;
            clock_t stop;
            double t = 0.0;
            /* Start timer */
            start = clock ();
            U64 count = perft (maxDepth);
            /* Stop timer */
            stop = clock ();
            t = (double) (stop - start) / CLOCKS_PER_SEC;
//            printf ("nodes = %'llu\n", count);
            printf ("nodes = %8"  PRId64 "\n", count); // Belka
            printf ("time = %.2f s\n", t);
            continue;
        }
        if (!strcmp (s, "quit"))
        {
            printf ("Good bye!\n");
            return 0;
        }

        /* Maybe the user entered a move? */
        from = s[0] - 'a';
        from += 8 * (8 - (s[1] - '0'));
        dest = s[2] - 'a';
        dest += 8 * (8 - (s[3] - '0'));
        ply = 0;
        movecnt = genMoves (side, moveBuf);

        /* Loop through the moves to see whether it's legal */
        for (i = 0; i < movecnt; i++)
            if (moveBuf[i].from == from && moveBuf[i].dest == dest)
            {
                /* Promotion move? */
                if (piece[from] == PAWN && (dest < 8 || dest > 55))
                {
                    switch (s[4])
                    {
                    case 'q':
                        moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_QUEEN;
                        break;

                    case 'r':
                        moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_ROOK;
                        break;

                    case 'b':
                        moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_BISHOP;
                        break;

                    case 'n':
                        moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_KNIGHT;
                        break;

                    default:
                        puts("Promoting to a McGuffin..., I'll give you a queen");
                        moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_QUEEN;
                    }
                }
                if (!makeMove (moveBuf[i]))
                {
                    takeBack ();
                    printf ("Illegal move.\n");
                }
                break;
            }
        printBoard ();
    }
}
int
main(int argc, char *argv[])
{
    {
        AdvancedStringContainer a;
        a << AdvancedString("");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");
        res.push_back(e);

        test1(a, res, 1);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString(" what");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString(" what");
        res.push_back(e);

        test1(a, res, 2);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("foo \n");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e, e2;
        e << AdvancedString("foo ");
        res.push_back(e);
        e << AdvancedString("");
        res.push_back(e2);

        test1(a, res, 3);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\n1\n\n1\n1\n1\n1\n");
        a << AdvancedString("\n\n1\n\n\n\n1");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");

        AdvancedStringContainer e1;
        e1 << AdvancedString("1");
        res.push_back(e);
        res.push_back(e1);
        res.push_back(e);

        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e);
        res.push_back(e);

        res.push_back(e1);
        res.push_back(e);
        res.push_back(e);
        res.push_back(e);
        res.push_back(e1);

        test1(a, res, 4);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\n1\n\n1\n1\n1\n1\n\n\n1\n\n\n\n1");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");

        AdvancedStringContainer e1;
        e1 << AdvancedString("1");

        res.push_back(e);
        res.push_back(e1);
        res.push_back(e);

        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e1);
        res.push_back(e);
        res.push_back(e);

        res.push_back(e1);
        res.push_back(e);
        res.push_back(e);
        res.push_back(e);
        res.push_back(e1);

        test1(a, res, 5);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("hello\nworld");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("hello");

        AdvancedStringContainer e1;
        e1 << AdvancedString("world");

        res.push_back(e);
        res.push_back(e1);

        test1(a, res, 6);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\nhelloworld");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");

        AdvancedStringContainer e1;
        e1 << AdvancedString("helloworld");

        res.push_back(e);
        res.push_back(e1);

        test1(a, res, 7);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\n11akf__\n__jaffka22")
          << AdvancedString("33akfkafk44\n55asdkfasdfk66")
          << AdvancedString("\n77afafaf88\n\n\nf");

        std::vector<AdvancedStringContainer> res;

        AdvancedStringContainer e, e1, e2, e3, e4, e5, e6, e7;
        e << AdvancedString("");
        res.push_back(e);

        e1 << AdvancedString("11akf__");
        res.push_back(e1);

        e2 << AdvancedString("__jaffka2233akfkafk44");
        res.push_back(e2);

        e3 << AdvancedString("55asdkfasdfk66");
        res.push_back(e3);

        e4 << AdvancedString("77afafaf88");
        res.push_back(e4);

        e5 << AdvancedString("");
        res.push_back(e5);

        e6 << AdvancedString("");
        res.push_back(e6);

        e7 << AdvancedString("f");
        res.push_back(e7);

        test1(a, res,8);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\n");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e, e2;
        e << AdvancedString("");
        res.push_back(e);

        e << AdvancedString("");
        res.push_back(e2);

        test1(a, res, 9);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("\n");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");

        res.push_back(e);
        res.push_back(e);

        test1(a, res, 10);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA);
        a << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN);
        a << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN);
        a << AdvancedString("\n\na");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e, e1, e2, e3, e4;

        e << AdvancedString("**this should be colored in MAGENTA**");
        res.push_back(e);

        e1 << AdvancedString("**this should be colored in GREEN**");
        res.push_back(e1);

        e2 << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444");
        res.push_back(e2);

        e3 << AdvancedString("");
        res.push_back(e3);
        res.push_back(e3);

        e4 << AdvancedString("a");
        res.push_back(e4);

        test1(a, res, 11);
    }

    {
        AdvancedStringContainer a;
        a << AdvancedString("  foo\n");
        a << AdvancedString(" bar  ");
        a << AdvancedString("   ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e,e1;
        e << AdvancedString("  foo");
        res.push_back(e);

        e1 << AdvancedString(" bar  ");
        e1 << AdvancedString("   ");
        res.push_back(e1);

        test1(a, res, 12);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("linux                          ");
        b << AdvancedString("for  \n      the  ");
        b << AdvancedString("ppl    ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e,e1;

        e << AdvancedString("linux                          for");
        e1 << AdvancedString("      the  ppl");
        res.push_back(e);
        res.push_back(e1);

        test2(b, res, 50);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");
        res.push_back(e);

        test2(b, res, 51);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("  ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");
        res.push_back(e);

        test2(b, res, 52);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("  ");
        b << AdvancedString("");
        b << AdvancedString("");
        b << AdvancedString("  ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e;
        e << AdvancedString("");
        res.push_back(e);

        test2(b, res, 53);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("  ");
        b << AdvancedString(" \n ");
        b << AdvancedString("  foo\n");
        b << AdvancedString(" bar  ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e,e1,e2,e3;
        e << AdvancedString("");
        res.push_back(e);
        e1 << AdvancedString("   foo");
        res.push_back(e1);
        e2 << AdvancedString(" bar");
        res.push_back(e2);

        test2(b, res, 54);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA);
        b << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN);
        b << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN);
        b << AdvancedString("\n\na");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e,e1,e2,e3,e4;
        e << AdvancedString("**this should be colored in MAGENTA**");
        res.push_back(e);

        e1 << AdvancedString("**this should be colored in GREEN**");
        res.push_back(e1);

        e2 << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444");
        res.push_back(e2);

        e3 << AdvancedString("");
        res.push_back(e3);
        res.push_back(e3);
        e4 << AdvancedString("a");

        res.push_back(e4);

        test2(b, res, 55);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("  foo\n");
        b << AdvancedString(" bar  ");
        b << AdvancedString("   ");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e1,e2;
        e1 << AdvancedString("  foo");
        res.push_back(e1);

        e2 << AdvancedString(" bar");
        res.push_back(e2);

        test2(b, res, 56);
    }

    {
        AdvancedStringContainer b;
        b << AdvancedString("123  \n");
        b << AdvancedString("  \n");
        b << AdvancedString("1lk2j312k3j");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e1,e2,e3;

        e1 << AdvancedString("123");
        res.push_back(e1);

        e2 << AdvancedString("");
        res.push_back(e2);

        e3 << AdvancedString("1lk2j312k3j");
        res.push_back(e3);

        test2(b, res, 57);
    }

    ////////////////////////// terminal_rasterize ///////////////////////

    {
        AdvancedStringContainer c;
        c << AdvancedString("\nhello worldhow are you today?");
        c << AdvancedString("this is funny stuff\n");
        c << AdvancedString("bye bye world");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e, e0, e1, e2, e3;

        e << AdvancedString(std::string(17, ' '));
        res.push_back(e);

        e0 << AdvancedString("hello worldhow ar");
        res.push_back(e0);

        e1 << AdvancedString("e you today?this ");
        res.push_back(e1);

        e2 << AdvancedString("is funny stuff   ");
        res.push_back(e2);

        e3 << AdvancedString("bye bye world    ");
        res.push_back(e3);

        test3(c, res, 17, 71);
    }

    {
        AdvancedStringContainer c;
        c << AdvancedString("\n\nmore and more\n questions arise?");
        c << AdvancedString("due to broken code\n\n");
        c << AdvancedString("so \nbye bye world\n");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e, e0, e1, e2, e3, e4, e5;

        e << AdvancedString(std::string(17, ' '));
        res.push_back(e);
        res.push_back(e);

        e0 << AdvancedString("more and more    ");
        res.push_back(e0);

        e1 << AdvancedString(" questions arise?");
        res.push_back(e1);

        e2 << AdvancedString("due to broken cod");
        res.push_back(e2);

        e3 << AdvancedString("e                ");
        res.push_back(e3);
        res.push_back(e);

        e4 << AdvancedString("so               ");
        res.push_back(e4);

        e5 << AdvancedString("bye bye world    ");
        res.push_back(e5);
//         res.push_back(e);

        test3(c, res, 17, 72);
    }

    {
        AdvancedStringContainer c;
        c << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA);
        c << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN);
        c << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN);
        c << AdvancedString("\n\na");

        std::vector<AdvancedStringContainer> res;
        AdvancedStringContainer e,e0,e1,e2,e3,e4,e5;

        e << AdvancedString(std::string(50, ' '));
        e0 << AdvancedString("**this should be colored in MAGENTA**             ");
        res.push_back(e0);

        e1 << AdvancedString("**this should be colored in GREEN**               ");
        res.push_back(e1);

        e2 << AdvancedString("----------------------1111111111111111111111111122");
        res.push_back(e2);

        e3 << AdvancedString("22222222222222222222222222222223333333333333333333");
        res.push_back(e3);

        e4 << AdvancedString("3333333333333334444444                            ");
        res.push_back(e4);
        res.push_back(e);
        res.push_back(e);

        e5 << AdvancedString("a                                                 ");
        res.push_back(e5);

        test3(c, res, 50, 73);
        std::vector<AdvancedStringContainer> buf;

//         AdvancedStringContainer::trimEndAndRemoveNewlineChars(buf, c);
//         std::cout << "==== NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN: ====" << std::endl;
//         for (int i=0; i < buf.size(); ++i) {
//             std::cout  << "'" << YELLOW << buf[i].str() << RESET << "'" << std::endl;
//         }
    }

    ////////////////////////// AdvancedString::substr //////////////////////

    {
        AdvancedString c("hello world");
        AdvancedString res("hello");
        test4(c, res, 0, 5, 90);
    }

    {
        AdvancedString c("hello world");
        AdvancedString res("");
        test4(c, res, 0, 0, 91);
    }

    {
        AdvancedString c("hello world");
        AdvancedString res(" world");
        test4(c, res, 5, 55, 92);
    }

    {
        AdvancedString c("hello world");
        AdvancedString res("");
        test4(c, res, 55, 55, 93);
    }

    {
        AdvancedString c("");
        AdvancedString res("");
        test4(c, res, 55, 55, 94);
    }

    {
        AdvancedString c("123");
        AdvancedString res("2");
        test4(c, res, 1, 1, 95);
    }

    //////////////////// AdvancedStringContainer::substr ///////////////////

    {
        AdvancedStringContainer c;
        c << "hello world" << ", how are " << "you";

        AdvancedStringContainer res;
        res << "hello world";

        test5(c, res, 0, 11, 110);
    }

    {
        AdvancedStringContainer c;
        c << "hello world" << ", how are " << "you";

        AdvancedStringContainer res;
        res << "llo world, how";

        test5(c, res, 2, 14, 111);
    }

    {
        AdvancedStringContainer c;
        c << "hello world" << ", how are " << "you";

        AdvancedStringContainer res;
        res << "llo world, how are y";

        test5(c, res, 2, 20, 112);
    }

    {
        AdvancedStringContainer c;
        c << "" << "hello world" << "" << ", how are " << "you";

        AdvancedStringContainer res;
        res << "llo world, how are y";

        test5(c, res, 2, 20, 113);
    }

    {
        AdvancedStringContainer c;
        c << "";

        AdvancedStringContainer res; // should be empty

        test5(c, res, 0, 11, 114);
    }

    {
        AdvancedStringContainer c;
        c << "" << "" << "";

        AdvancedStringContainer res; // should be empty

        test5(c, res, 0, 11, 115);
    }

    {
        AdvancedStringContainer c;
        c << "" << "" << "" << "f" << "";

        AdvancedStringContainer res;
        res << "f";

        test5(c, res, 0, 1, 116);
    }

    exit(0);
}
int main ()
{
  v2sf a, b, c, d;
  int i, j;

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {33, 44};
  c = (v2sf) {55, 66};
  d = (v2sf) {77, 88};
  i = 0;
  j = 0;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {11, 44};
  c = (v2sf) {55, 66};
  d = (v2sf) {77, 88};
  i = 1;
  j = 0;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {33, 22};
  c = (v2sf) {55, 66};
  d = (v2sf) {77, 88};
  i = 1;
  j = 0;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {33, 44};
  c = (v2sf) {55, 66};
  d = (v2sf) {55, 88};
  i = 1;
  j = 0;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {33, 44};
  c = (v2sf) {55, 66};
  d = (v2sf) {77, 66};
  i = 1;
  j = 0;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* c.eq.ps */
  a = (v2sf) {11, 22};
  b = (v2sf) {11, 22};
  c = (v2sf) {55, 66};
  d = (v2sf) {55, 66};
  i = 1;
  j = 1;
  if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i)
    abort ();
  if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j)
    abort ();

  /* Test all comparisons */
  a = (v2sf) {11, 33};
  b = (v2sf) {33, 11};
  c = (v2sf) {55, 66};
  d = (v2sf) {55, 88};

  i = test0 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test1 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test2 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test3 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test4 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test5 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test6 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test7 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test8 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test9 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test10 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test11 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test12 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test13 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test14 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test15 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test16 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test17 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test18 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test19 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test20 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test21 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test22 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test23 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test24 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test25 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test26 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test27 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test28 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test29 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test30 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test31 (a, b, c, d);
  if (i != 0)
    abort ();

  /* Reversed arguments */
  i = test0 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test1 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test2 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test3 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test4 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test5 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test6 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test7 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test8 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test9 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test10 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test11 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test12 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test13 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test14 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test15 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test16 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test17 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test18 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test19 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test20 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test21 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test22 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test23 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test24 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test25 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test26 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test27 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test28 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test29 (b, a, d, c);
  if (i != 0)
    abort ();
  i = test30 (b, a, d, c);
  if (i != 1)
    abort ();
  i = test31 (b, a, d, c);
  if (i != 0)
    abort ();

#ifndef __FAST_MATH__
  /* Test all comparisons */
  a = (v2sf) {qnan, qnan};
  b = (v2sf) {33, 11};
  c = (v2sf) {qnan, qnan};
  d = (v2sf) {55, 88};

  i = test0 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test1 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test2 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test3 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test4 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test5 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test6 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test7 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test8 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test9 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test10 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test11 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test12 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test13 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test14 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test15 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test16 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test17 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test18 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test19 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test20 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test21 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test22 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test23 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test24 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test25 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test26 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test27 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test28 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test29 (a, b, c, d);
  if (i != 0)
    abort ();
  i = test30 (a, b, c, d);
  if (i != 1)
    abort ();
  i = test31 (a, b, c, d);
  if (i != 1)
    abort ();
#endif

  printf ("Test Passes\n");
  exit (0);
}
Exemple #11
0
int main(int argc, char **argv)
{
	uint32 retval;

	/*
	kprintf("main: calling getlocalip\n");
	retval = getlocalip();

	if (retval == SYSERR) {
		kprintf("I'm here to stop!\n");
	} else {
		kprintf("I'm here to continue!\n");
		kprintf("\n\n###########################################################\n\n");
		kprintf("IP address is %d.%d.%d.%d   %08x\n\r",
			(retval>>24)&0xff, (retval>>16)&0xff, (retval>>8)&0xff,
		 	retval&0xff,retval);

	    	kprintf("Subnet mask is %d.%d.%d.%d and router is %d.%d.%d.%d\n\r",
			(NetData.addrmask>>24)&0xff, (NetData.addrmask>>16)&0xff,
			(NetData.addrmask>> 8)&0xff,  NetData.addrmask&0xff,
			(NetData.routeraddr>>24)&0xff, (NetData.routeraddr>>16)&0xff,
			(NetData.routeraddr>> 8)&0xff, NetData.routeraddr&0xff);
	}
	*/
	
	//BEG Lab1_______________________________________________________
	/*kprintf("%x\n",host2netl_asm (0x12345678));
	//long test_asm_val;
	//long testa = 3;
	//test_asm_val = host2netl_asm(testa);
	//kprintf("host2netl_asm: %s \r\n\r\n", test_asm_val);
	printsegaddress();
	printprocstks();
	myprogA();

	kprintf("\r\nSpawning Processes...\r\n");
	resume(create(myprogA,1024,20,"Process A",0));
	//resume(create(myprogA,1024,20,"Process 2",0));
	printprocstks();*/
	//END Lab1_______________________________________________________
	

	//BEG Lab2_______________________________________________________
	//1024, 20priority, nameProcess, 1 arg, char
	
	/*
	uint32 pidA, pidB,pidC;
	pidA = create(printloop,1024,10,"Process A",1,'A');
	pidB = create(printloop,1024,10,"Process B",1,'B');
	pidC = create(printloop,1024,10,"Process C",1,'C');
	//pidA = create(printloop,1024,6,"Process A",1,'A');
	//pidB = create(printloop,1024,8,"Process B",1,'B');
	//pidC = create(printloop,1024,10,"Process C",1,'C');
	
	kprintf("P\r\n");
	resume(pidA);
	kprintf("P\r\n");
	resume(pidB);
	kprintf("P\r\n");
	resume(pidC);
	
	//sleep for 5 seconds
	//sleepms(5000);
	sleepms(5000);
	*/
	
	//END Lab2_______________________________________________________
	
	//BEG Lab3_______________________________________________________
	//1024, 20priority, nameProcess, 1 arg, char
	
	test1();
	sleepms(5000);
	test2();
	sleepms(5000);
	
	test4();
//	resume(create(cpuintensive, 1024, 20, "cpuintensiveA", 0));
//	resume(create(cpuintensive, 1024, 20, "cpuintensiveB", 0));
//	resume(create(cpuintensive, 1024, 20, "cpuintensiveC", 0)); 
//    resume(create(cpuintensive, 1024, 20, "cpuintensiveD", 0));
	//resume(create(cpuintensive, 1024, 20, "cpuintensiveE", 0));
	//resume(create(cpuintensive, 1024, 20, "cpuintensiveF", 0));
	
	
	/*
	resume(create(iointensive, 1024, 20, "iointensiveA", 0));
	resume(create(iointensive, 1024, 20, "iointensiveB", 0));
	resume(create(iointensive, 1024, 20, "iointensiveC", 0));
    resume(create(iointensive, 1024, 20, "iointensiveD", 0));
	resume(create(iointensive, 1024, 20, "iointensiveE", 0));
	resume(create(iointensive, 1024, 20, "iointensiveF", 0));
	*/
	
	/*
	uint32 pidA, pidB,pidC;
	pidA = create(printloop,1024,10,"Process A",1,'A');
	pidB = create(printloop,1024,10,"Process B",1,'B');
	pidC = create(printloop,1024,10,"Process C",1,'C');
	//pidA = create(printloop,1024,6,"Process A",1,'A');
	//pidB = create(printloop,1024,8,"Process B",1,'B');
	//pidC = create(printloop,1024,10,"Process C",1,'C');
	
	kprintf("P\r\n");
	resume(pidA);
	kprintf("P\r\n");
	resume(pidB);
	kprintf("P\r\n");
	resume(pidC);
	
	//sleep for 5 seconds
	//sleepms(5000);
	sleepms(5000);
	*/
	
	//END Lab3_______________________________________________________

	//comment out following line before, uncommented out lab 3
	while (1);
	
	//Kalena commented out following line for lab3
	//resume(create(shell, 8192, 50, "shell", 1, CONSOLE));	

	/* Wait for shell to exit and recreate it */
	recvclr();
	while (TRUE) {
		retval = receive();
		kprintf("\n\n\rMain process recreating shell\n\n\r");
		resume(create(shell, 4096, 1, "shell", 1, CONSOLE));
	}

	return OK;
}
Exemple #12
0
void test() {
    uart_putchar('a');
    test2();
    uart_putchar('c');
} 
Exemple #13
0
int main(int argc, char **argv)
{
	const char *chset=unicode_x_imap_modutf7;
	int argn=1;

	if (argn < argc && strcmp(argv[argn], "--smap") == 0)
	{
		chset=unicode_x_imap_modutf7 " ./~:";
		++argn;
	}

	if (argn < argc && strcmp(argv[argn], "--totitle") == 0)
	{
		++argn;

		if (argn < argc)
		{
			char *p=libmail_u_convert_tocase(argv[argn],
							 "utf-8",
							 unicode_tc,
							 unicode_lc);

			if (p)
			{
				printf("%s\n", p);
				free(p);
				exit(0);
			}
		}
		exit(1);
	}

	if (argn < argc)
	{
		int errflag;
		char *p=libmail_u_convert_tobuf(argv[argn],
						"utf-8",
						chset,
						&errflag);
		char *q;

		if (!p)
		{
			perror("libmail_u_convert");
			exit(1);
		}

		if (errflag)
		{
			fprintf(stderr, "Conversion error?\n");
			exit(1);
		}

		q=libmail_u_convert_tobuf(p, chset, "utf-8", &errflag);
		if (!q)
		{
			perror("libmail_u_convert");
			exit(1);
		}

		if (errflag)
		{
			fprintf(stderr, "Conversion error?\n");
			exit(1);
		}
		if (strcmp(q, argv[argn]))
		{
			fprintf(stderr, "Round trip error\n");
			exit(1);
		}
		printf("%s\n", p);
		free(p);
		free(q);
	}
	else
	{
		test1();
		test2();
	}
	return 0;
}
Exemple #14
0
int main(int argc, char** argv)
{

// Execute the tests only if trace calls are included

#ifdef PEGASUS_REMOVE_TRACE
    cout << argv[0] << " +++++ passed all tests" << endl;
    return 0;
#else

    const char* tmpDir = getenv ("PEGASUS_TMP");
    if (tmpDir == NULL)
    {
        tmpDir = ".";
    }
    String f1 (tmpDir);
    f1.append("/testtracer1.trace");
    FILE1 = f1.getCString();
    String f2 (tmpDir);
    f2.append("/testtracer2.trace");
    FILE2 = f2.getCString();
    String f3 (tmpDir);
    f3.append("/testtracer3.trace");
    FILE3 = f3.getCString();
    String f4 (tmpDir);
    f4.append("/testtracer4.trace");
    FILE4 = f4.getCString();

    System::removeFile(FILE1);
    System::removeFile(FILE2);
    System::removeFile(FILE3);
    System::removeFile(FILE4);
    if (test1() == 0)
    {
       cout << "Tracer test (test1) failed" << endl;
       exit(1);
    }
    if (test2() == 0)
    {
       cout << "Tracer test (test2) failed" << endl;
       exit(1);
    }
    if (test3() == 0)
    {
       cout << "Tracer test (test3) failed" << endl;
       exit(1);
    }
    if (test4() != 0)
    {
       cout << "Tracer test (test4) failed" << endl;
       exit(1);
    }
    if (test5() != 0)
    {
       cout << "Tracer test (test5) failed" << endl;
       exit(1);
    }
    if (test6() != 0)
    {
       cout << "Tracer test (test6) failed" << endl;
       exit(1);
    }
    if (test7() != 0)
    {
       cout << "Tracer test (test7) failed" << endl;
       exit(1);
    }
    if (test8() != 0)
    {
       cout << "Tracer test (test8) failed" << endl;
       exit(1);
    }
    if (test9() != 0)
    {
       cout << "Tracer test (test9) failed" << endl;
       exit(1);
    }
    if (test10() != 0)
    {
       cout << "Tracer test (test10) failed" << endl;
       exit(1);
    }
    if (test11() != 0)
    {
       cout << "Tracer test (test11) failed" << endl;
       exit(1);
    }
    if (test12() != 0)
    {
       cout << "Tracer test (test12) failed" << endl;
       exit(1);
    }
    if (test13() != 0)
    {
       cout << "Tracer test (test13) failed" << endl;
       exit(1);
    }
    if (test14() != 0)
    {
       cout << "Tracer test (test14) failed" << endl;
       exit(1);
    }
    if (test15() != 0)
    {
       cout << "Tracer test (test15) failed" << endl;
       exit(1);
    }
    if (test16() != 0)
    {
       cout << "Tracer test (test16) failed" << endl;
       exit(1);
    }
    if (test17() != 0)
    {
       cout << "Tracer test (test17) failed" << endl;
       exit(1);
    }
    if (test18() != 0)
    {
       cout << "Tracer test (test18) failed" << endl;
       exit(1);
    }
    if (test19() != 0)
    {
       cout << "Tracer test (test19) failed" << endl;
       exit(1);
    }
    if (test20() != 0)
    {
       cout << "Tracer test (test20) failed" << endl;
       exit(1);
    }
    if (test21() != 0)
    {
       cout << "Tracer test (test21) failed" << endl;
       exit(1);
    }
    if (test22() != 0)
    {
       cout << "Tracer test (test22) failed" << endl;
       exit(1);
    }
    cout << argv[0] << " +++++ passed all tests" << endl;
    System::removeFile(FILE1);
    System::removeFile(FILE2);
    System::removeFile(FILE3);
    System::removeFile(FILE4);
    return 0;
#endif
}
Exemple #15
0
/*
 * main -- バッファ管理モジュールのテスト
 */
int main(int argc, char **argv)
{
    File *file[2];
    char page1[PAGE_SIZE], page2[PAGE_SIZE];
    int i;
    
    /* 乱数用関数の初期化 */
    initializeRandomGenerator();
    
    /*
     * ファイルアクセスモジュールの初期化
     */
    if (initializeFileModule() != OK) {
        fprintf(stderr, "%s: initialization failed.\n", TEST_NAME);
    }
    
    /*
     * 前回このプログラムを実行したときのテストファイルが
     * 残っている可能性があるので、まず消去する
     */
    deleteFile(TEST_FILE1);
    deleteFile(TEST_FILE2);
    
    /* 空のファイルを2つ作り、オープンする */
    if (createFile(TEST_FILE1) != OK) {
        fprintf(stderr, "Cannot create file.\n");
        exit(1);
    }
    
    if (createFile(TEST_FILE2) != OK) {
        fprintf(stderr, "Cannot create file.\n");
        exit(1);
    }
    
    if ((file[0] = openFile(TEST_FILE1)) == NULL) {
        fprintf(stderr, "Cannot open file.\n");
        exit(1);
    }
    
    if ((file[1] = openFile(TEST_FILE2)) == NULL) {
        fprintf(stderr, "Cannot open file.\n");
        exit(1);
    }
    
    /*
     * ファイルの先頭から順に、(FILE_SIZE)ページ分のダミーデータを書く
     *
     * それぞれのページの先頭3バイトに、以下のように文字を書く
     * file1:
     *   0ページ目: 000
     *   1ページ目: 001
     *   2ページ目: 002
     *   (以下同様)
     * file2:
     *   0ページ目: 100
     *   1ページ目: 101
     *   2ページ目: 102
     *   (以下同様)
     */
    for (i = 0; i < FILE_SIZE; i++) {
        /* ページに書く内容を用意する */
        memset(page1, 0, PAGE_SIZE);
        memset(page2, 0, PAGE_SIZE);
        sprintf(page1, "00%c", '0' + i);
        sprintf(page2, "10%c", '0' + i);
        
        /* ファイルに書き込む */
        if (writePage(file[0], i, page1) != OK) {
            fprintf(stderr, "Cannot write page.\n");
            exit(1);
        }
        
        if (writePage(file[1], i, page2) != OK) {
            fprintf(stderr, "Cannot write page.\n");
            exit(1);
        }
    }
    
    /* いったんファイルをクローズする */
    closeFile(file[0]);
    closeFile(file[1]);
    
    /*
     * ここまでが下準備。ここからバッファリング機能をテストする
     */
    test1();
    test2();
    
    /*
     * ファイルアクセスモジュールの終了処理
     */
    if (finalizeFileModule() != OK) {
        fprintf(stderr, "%s: finalization failed.\n", TEST_NAME);
    }
    
    /* ファイルを削除する */
    deleteFile(TEST_FILE1);
    deleteFile(TEST_FILE2);
}
Exemple #16
0
void main() {
	srand(time(NULL));
	test2();
}
Exemple #17
0
int main ( int argc, char* argv[] ) {
	// test1 ( );
	test2 ( );
	test3 ( );
	test4 ( );
}
Exemple #18
0
int main() {
  {

    static_assert(
        ranges::detail::BidirectionalCursor<
        ranges::detail::reverse_cursor<bidirectional_iterator<const char *>>>{},
        "");
    static_assert(
        ranges::detail::BidirectionalCursor<
        ranges::detail::reverse_cursor<random_access_iterator<const char *>>>{},
        "");
    static_assert(
        ranges::detail::RandomAccessCursor<
        ranges::detail::reverse_cursor<random_access_iterator<const char *>>>{},
        "");
    static_assert(
        ranges::BidirectionalIterator<
            ranges::reverse_iterator<bidirectional_iterator<const char *>>>{},
        "");
    static_assert(
        ranges::RandomAccessIterator<
            ranges::reverse_iterator<random_access_iterator<const char *>>>{},
        "");
  }
  { // test
    test<bidirectional_iterator<const char *>>();
    test<random_access_iterator<char *>>();
    test<char *>();
    test<const char *>();
  }
  { // test 2
    const char s[] = "123";
    test2(bidirectional_iterator<const char *>(s));
    test2(random_access_iterator<const char *>(s));
  }
  { // test3
    Derived d;
    test3<bidirectional_iterator<Base *>>(
        bidirectional_iterator<Derived *>(&d));
    test3<random_access_iterator<const Base *>>(
        random_access_iterator<Derived *>(&d));
  }
  { // test4
    const char *s = "1234567890";
    random_access_iterator<const char *> b(s);
    random_access_iterator<const char *> e(s + 10);
    while (b != e)
      test4(b++);
  }
  { // test5
    const char *s = "1234567890";
    test5(bidirectional_iterator<const char *>(s),
          bidirectional_iterator<const char *>(s), false);
    test5(bidirectional_iterator<const char *>(s),
          bidirectional_iterator<const char *>(s + 1), true);
    test5(random_access_iterator<const char *>(s),
          random_access_iterator<const char *>(s), false);
    test5(random_access_iterator<const char *>(s),
          random_access_iterator<const char *>(s + 1), true);
    test5(s, s, false);
    test5(s, s + 1, true);
  }
  {
    const char *s = "123";
    test6(bidirectional_iterator<const char *>(s + 1),
          bidirectional_iterator<const char *>(s));
    test6(random_access_iterator<const char *>(s + 1),
          random_access_iterator<const char *>(s));
    test6(s + 1, s);
  }
  {
    const char *s = "123";
    test7(bidirectional_iterator<const char *>(s + 1),
          bidirectional_iterator<const char *>(s));
    test7(random_access_iterator<const char *>(s + 1),
          random_access_iterator<const char *>(s));
    test7(s + 1, s);
  }
  {
    const char *s = "1234567890";
    test8(random_access_iterator<const char *>(s + 5), 5,
          random_access_iterator<const char *>(s));
    test8(s + 5, 5, s);
  }
  {
    const char *s = "1234567890";
    test9(random_access_iterator<const char *>(s + 5), 5,
          random_access_iterator<const char *>(s));
    test9(s + 5, 5, s);
  }
  {
    const char *s = "123";
    test10(bidirectional_iterator<const char *>(s + 1),
           bidirectional_iterator<const char *>(s + 2));
    test10(random_access_iterator<const char *>(s + 1),
           random_access_iterator<const char *>(s + 2));
    test10(s + 1, s + 2);
  }
  {
    const char *s = "123";
    test11(bidirectional_iterator<const char *>(s + 1),
           bidirectional_iterator<const char *>(s + 2));
    test11(random_access_iterator<const char *>(s + 1),
           random_access_iterator<const char *>(s + 2));
    test11(s + 1, s + 2);
  }
  {
    const char *s = "1234567890";
    test12(random_access_iterator<const char *>(s + 5), 5,
           random_access_iterator<const char *>(s + 10));
    test12(s + 5, 5, s + 10);
  }
  {
    const char *s = "1234567890";
    test13(random_access_iterator<const char *>(s + 5), 5,
           random_access_iterator<const char *>(s + 10));
    test13(s + 5, 5, s + 10);
  }
  {
    A a;
    test14(&a + 1, A());
  }
  {
    Derived d;

    test15<bidirectional_iterator<Base *>>(
        bidirectional_iterator<Derived *>(&d));
    test15<random_access_iterator<const Base *>>(
        random_access_iterator<Derived *>(&d));
    test15<Base *>(&d);
  }
  {
    const char *s = "1234567890";
    test16(bidirectional_iterator<const char *>(s),
           bidirectional_iterator<const char *>(s), true);
    test16(bidirectional_iterator<const char *>(s),
           bidirectional_iterator<const char *>(s + 1), false);
    test16(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s), true);
    test16(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s + 1), false);
    test16(s, s, true);
    test16(s, s + 1, false);
  }
  {
    char s[3] = {0};
    test17(random_access_iterator<const char *>(s),
           random_access_iterator<char *>(s), 0);
    random_access_iterator<char *> inp1(s);
    test17(random_access_iterator<char *>(s),
           random_access_iterator<const char *>(s + 1), 1);
    test17(random_access_iterator<const char *>(s + 1),
           random_access_iterator<char *>(s), -1);
    test17(s, s, 0);
    test17(s, s + 1, 1);
    test17(s + 1, s, -1);
  }
  {
    const char *s = "1234567890";
    test18(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s), false);
    test18(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s + 1), true);
    test18(random_access_iterator<const char *>(s + 1),
           random_access_iterator<const char *>(s), false);
    test18(s, s, false);
    test18(s, s + 1, true);
    test18(s + 1, s, false);
  }
  {
    const char *s = "1234567890";
    test19(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s), true);
    test19(random_access_iterator<const char *>(s),
           random_access_iterator<const char *>(s + 1), true);
    test19(random_access_iterator<const char *>(s + 1),
           random_access_iterator<const char *>(s), false);
    test19(s, s, true);
    test19(s, s + 1, true);
    test19(s + 1, s, false);
  }
  {
    const char *s = "1234567890";
    test20(random_access_iterator<const char *>(s + 5), 4, '1');
    test20(s + 5, 4, '1');
  }
  {
    const char *s = "1234567890";
    test21(random_access_iterator<const char *>(s),
         random_access_iterator<const char *>(s), false);
    test21(random_access_iterator<const char *>(s),
         random_access_iterator<const char *>(s + 1), false);
    test21(random_access_iterator<const char *>(s + 1),
         random_access_iterator<const char *>(s), true);
    test21(s, s, false);
    test21(s, s + 1, false);
    test21(s + 1, s, true);
  }
  {
      const char* s = "1234567890";
      test22(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
      test22(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
      test22(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
      test22(s, s, false);
      test22(s, s+1, false);
      test22(s+1, s, true);
  }
  {
      const char* s = "1234567890";
      test23(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
      test23(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
      test23(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
      test23(s, s, true);
      test23(s, s+1, false);
      test23(s+1, s, true);
  }
  {
      B a;
      test24(&a+1, B());
  }
  {
      C l[3] = {C(0), C(1), C(2)};

      auto ri = ranges::rbegin(l);
      CHECK ( (*ri).get() == 2 );  ++ri;
      CHECK ( (*ri).get() == 1 );  ++ri;
      CHECK ( (*ri).get() == 0 );  ++ri;
      CHECK ( ri == ranges::rend(l));
  }
  {
      const char* s = "1234567890";
      test25(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
      test25(s+5, 5, s);
  }

  return test_result();
}
Exemple #19
0
void main() {
    test1();
    InitFMem(BasicAlloc, BasicFree, NULL, NULL);
    test2();
}
Exemple #20
0
int
main (void)
{
  mp_rnd_t rnd;
  mp_prec_t p;
  MPFR_TEST_USE_RANDS ();
  tests_start_mpfr ();

  p = (randlimb () % 200)+ MPFR_PREC_MIN;
  RND_LOOP (rnd)
    {
      test3 (mpfr_add, "mpfr_add", p, rnd);
      test3 (mpfr_sub, "mpfr_sub", p, rnd);
      test3 (mpfr_mul, "mpfr_mul", p, rnd);
      test3 (mpfr_div, "mpfr_div", p, rnd);

      test3 (mpfr_agm, "mpfr_agm", p, rnd);
      test3 (mpfr_min, "mpfr_min", p, rnd);
      test3 (mpfr_max, "mpfr_max", p, rnd);
      test3 (reldiff_wrapper, "mpfr_reldiff", p, rnd);

      test2a (mpfr_round, "mpfr_round", p);
      test2a (mpfr_ceil, "mpfr_ceil", p);
      test2a (mpfr_floor, "mpfr_floor", p);
      test2a (mpfr_trunc, "mpfr_trunc", p);

      test2ui (mpfr_add_ui, "mpfr_add_ui", p, rnd);
      test2ui (mpfr_mul_2exp, "mpfr_mul_2exp", p, rnd);
      test2ui (mpfr_mul_ui, "mpfr_mul_ui", p, rnd);
      test2ui (mpfr_pow_ui, "mpfr_pow_ui", p, rnd);
      test2ui (mpfr_sub_ui, "mpfr_sub_ui", p, rnd);
      test2ui (mpfr_div_2exp, "mpfr_div_2exp", p, rnd);
      test2ui (mpfr_div_ui, "mpfr_div_ui", p, rnd);

      testui2 (mpfr_ui_div, "mpfr_ui_div", p, rnd);
      testui2 (mpfr_ui_sub, "mpfr_ui_sub", p, rnd);
      testui2 (mpfr_ui_pow, "mpfr_ui_pow", p, rnd);

      test2 (mpfr_sqr, "mpfr_sqr", p, rnd);
      test2 (mpfr_sqrt, "mpfr_sqrt", p, rnd);
      test2 (mpfr_abs, "mpfr_abs", p, rnd);
      test2 (mpfr_neg, "mpfr_neg", p, rnd);

      test2 (mpfr_log, "mpfr_log", p, rnd);
      test2 (mpfr_log2, "mpfr_log2", p, rnd);
      test2 (mpfr_log10, "mpfr_log10", p, rnd);
      test2 (mpfr_log1p, "mpfr_log1p", p, rnd);

      test2 (mpfr_exp, "mpfr_exp", p, rnd);
      test2 (mpfr_exp2, "mpfr_exp2", p, rnd);
      test2 (mpfr_exp10, "mpfr_exp10", p, rnd);
      test2 (mpfr_expm1, "mpfr_expm1", p, rnd);
      test2 (mpfr_eint, "mpfr_eint", p, rnd);

      test2 (mpfr_sinh, "mpfr_sinh", p, rnd);
      test2 (mpfr_cosh, "mpfr_cosh", p, rnd);
      test2 (mpfr_tanh, "mpfr_tanh", p, rnd);
      test2 (mpfr_asinh, "mpfr_asinh", p, rnd);
      test2 (mpfr_acosh, "mpfr_acosh", p, rnd);
      test2 (mpfr_atanh, "mpfr_atanh", p, rnd);

      test2 (mpfr_asin, "mpfr_asin", p, rnd);
      test2 (mpfr_acos, "mpfr_acos", p, rnd);
      test2 (mpfr_atan, "mpfr_atan", p, rnd);
      test2 (mpfr_cos, "mpfr_cos", p, rnd);
      test2 (mpfr_sin, "mpfr_sin", p, rnd);
      test2 (mpfr_tan, "mpfr_tan", p, rnd);

      test2 (mpfr_sec, "mpfr_sec", p, rnd);
      test2 (mpfr_csc, "mpfr_csc", p, rnd);
      test2 (mpfr_cot, "mpfr_cot", p, rnd);

      test2 (mpfr_erf,  "mpfr_erf",  p, rnd);
      test2 (mpfr_erfc, "mpfr_erfc", p, rnd);
      test2 (mpfr_j0,   "mpfr_j0",   p, rnd);
      test2 (mpfr_j1,   "mpfr_j1",   p, rnd);

      test2 (mpfr_zeta, "mpfr_zeta", p, rnd);
      test2 (mpfr_gamma, "mpfr_gamma", p, rnd);
      test2 (mpfr_rint, "mpfr_rint", p, rnd);
      test2 (mpfr_frac, "mpfr_frac", p, rnd);

      test3 (mpfr_pow, "mpfr_pow", p, rnd);
      test3 (mpfr_atan2, "mpfr_atan2", p, rnd);

      test4 (mpfr_fma, "mpfr_fma", p, rnd);
    }

  tests_end_mpfr ();
  return 0;
}
Exemple #21
0
int main()
{
    test1(0x4000/*U*/);
    test2(0x4000/*U*/);
    return 0;
}
void
ResourceBundleTest::TestConstruction()
{
    UErrorCode   err = U_ZERO_ERROR;
    Locale       locale("te", "IN");

    const char* testdatapath=loadTestData(err);
    if(U_FAILURE(err))
    {
        errln("Could not load testdata.dat " + UnicodeString(testdatapath) +  ", " + UnicodeString(u_errorName(err)));
        return;
    }

    /* Make sure that users using te_IN for the default locale don't get test failures. */
    Locale originalDefault;
    if (Locale::getDefault() == Locale("te_IN")) {
        Locale::setDefault(Locale("en_US"), err);
    }

    ResourceBundle  test1((UnicodeString)testdatapath, err);
    ResourceBundle  test2(testdatapath, locale, err);
    //ResourceBundle  test1("c:\\icu\\icu\\source\\test\\testdata\\testdata", err);
    //ResourceBundle  test2("c:\\icu\\icu\\source\\test\\testdata\\testdata", locale, err);

    UnicodeString   result1(test1.getStringEx("string_in_Root_te_te_IN", err));
    UnicodeString   result2(test2.getStringEx("string_in_Root_te_te_IN", err));

    if (U_FAILURE(err)) {
        errln("Something threw an error in TestConstruction()");
        return;
    }

    logln("for string_in_Root_te_te_IN, default.txt had " + result1);
    logln("for string_in_Root_te_te_IN, te_IN.txt had " + result2);

    if (result1 != "ROOT" || result2 != "TE_IN")
        errln("Construction test failed; run verbose for more information");

    const char* version1;
    const char* version2;

    version1 = test1.getVersionNumber();
    version2 = test2.getVersionNumber();

    char *versionID1 = new char[1+strlen(version1)]; // + 1 for zero byte
    char *versionID2 = new char[1+ strlen(version2)]; // + 1 for zero byte

    strcpy(versionID1, "44.0");  // hardcoded, please change if the default.txt file or ResourceBundle::kVersionSeparater is changed.

    strcpy(versionID2, "55.0");  // hardcoded, please change if the te_IN.txt file or ResourceBundle::kVersionSeparater is changed.

    logln(UnicodeString("getVersionNumber on default.txt returned ") + version1);
    logln(UnicodeString("getVersionNumber on te_IN.txt returned ") + version2);

    if (strcmp(version1, versionID1) != 0 || strcmp(version2, versionID2) != 0)
        errln("getVersionNumber() failed");

    delete[] versionID1;
    delete[] versionID2;

    /* Restore the default locale for the other tests. */
    Locale::setDefault(originalDefault, err);
}
Exemple #23
0
int main () {
    typedef std::experimental::string_view    string_view;
    typedef std::experimental::u16string_view u16string_view;
    typedef std::experimental::u32string_view u32string_view;
    typedef std::experimental::wstring_view   wstring_view;

    test1<string_view> ();
    test1<u16string_view> ();
    test1<u32string_view> ();
    test1<wstring_view> ();

    test2 ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
    test2 ( "ABCDE", 5 );
    test2 ( "a", 1 );
    test2 ( "", 0 );

    test2 ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
    test2 ( L"ABCDE", 5 );
    test2 ( L"a", 1 );
    test2 ( L"", 0 );

#if TEST_STD_VER >= 11
    test2 ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
    test2 ( u"ABCDE", 5 );
    test2 ( u"a", 1 );
    test2 ( u"", 0 );

    test2 ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
    test2 ( U"ABCDE", 5 );
    test2 ( U"a", 1 );
    test2 ( U"", 0 );
#endif
}
/*
 * Test special case inputs in atan2(), where the exact value of y/x is
 * zero or non-finite.
 */
static void
test_special_atan2(void)
{
	long double z;
	int e;

#if !__APPLE__ && !__gnu_linux__
	testall2(atan2, 0.0, -0.0, pi, FE_INEXACT);
	testall2(atan2, -0.0, -0.0, -pi, FE_INEXACT);
#endif /* !__APPLE__ && !__gnu_linux__ */
	testall2(atan2, 0.0, 0.0, 0.0, 0);
	testall2(atan2, -0.0, 0.0, -0.0, 0);

#if !__gnu_linux__
	testall2(atan2, INFINITY, -INFINITY, c3pi / 4, FE_INEXACT);
	testall2(atan2, -INFINITY, -INFINITY, -c3pi / 4, FE_INEXACT);
	testall2(atan2, INFINITY, INFINITY, pi / 4, FE_INEXACT);
	testall2(atan2, -INFINITY, INFINITY, -pi / 4, FE_INEXACT);
#endif /* !__gnu_linux__ */

	/* Tests with one input in the range (0, Inf]. */
	z = 1.23456789L;
	for (e = FLT_MIN_EXP - FLT_MANT_DIG; e <= FLT_MAX_EXP; e++) {
#if !__APPLE__
		test2(atan2f, 0.0, ldexpf(z, e), 0.0, 0);
		test2(atan2f, -0.0, ldexpf(z, e), -0.0, 0);
		test2(atan2f, 0.0, ldexpf(-z, e), (float)pi, FE_INEXACT);
		test2(atan2f, -0.0, ldexpf(-z, e), (float)-pi, FE_INEXACT);
#endif /* !__APPLE__ */
		test2(atan2f, ldexpf(z, e), 0.0, (float)pi / 2, FE_INEXACT);
		test2(atan2f, ldexpf(z, e), -0.0, (float)pi / 2, FE_INEXACT);
		test2(atan2f, ldexpf(-z, e), 0.0, (float)-pi / 2, FE_INEXACT);
		test2(atan2f, ldexpf(-z, e), -0.0, (float)-pi / 2, FE_INEXACT);
	}
	for (e = DBL_MIN_EXP - DBL_MANT_DIG; e <= DBL_MAX_EXP; e++) {
		test2(atan2, 0.0, ldexp(z, e), 0.0, 0);
		test2(atan2, -0.0, ldexp(z, e), -0.0, 0);
#if !__gnu_linux__
		test2(atan2, 0.0, ldexp(-z, e), (double)pi, FE_INEXACT);
		test2(atan2, -0.0, ldexp(-z, e), (double)-pi, FE_INEXACT);
		test2(atan2, ldexp(z, e), 0.0, (double)pi / 2, FE_INEXACT);
		test2(atan2, ldexp(z, e), -0.0, (double)pi / 2, FE_INEXACT);
		test2(atan2, ldexp(-z, e), 0.0, (double)-pi / 2, FE_INEXACT);
		test2(atan2, ldexp(-z, e), -0.0, (double)-pi / 2, FE_INEXACT);
#endif /* !__gnu_linux__ */
	}
	for (e = LDBL_MIN_EXP - LDBL_MANT_DIG; e <= LDBL_MAX_EXP; e++) {
		test2(atan2l, 0.0, ldexpl(z, e), 0.0, 0);
		test2(atan2l, -0.0, ldexpl(z, e), -0.0, 0);
		test2(atan2l, 0.0, ldexpl(-z, e), pi, FE_INEXACT);
		test2(atan2l, -0.0, ldexpl(-z, e), -pi, FE_INEXACT);
		test2(atan2l, ldexpl(z, e), 0.0, pi / 2, FE_INEXACT);
		test2(atan2l, ldexpl(z, e), -0.0, pi / 2, FE_INEXACT);
		test2(atan2l, ldexpl(-z, e), 0.0, -pi / 2, FE_INEXACT);
		test2(atan2l, ldexpl(-z, e), -0.0, -pi / 2, FE_INEXACT);
	}

	/* Tests with one input in the range (0, Inf). */
	for (e = FLT_MIN_EXP - FLT_MANT_DIG; e <= FLT_MAX_EXP - 1; e++) {
#if !__APPLE__
		test2(atan2f, ldexpf(z, e), INFINITY, 0.0, 0);
		test2(atan2f, ldexpf(-z,e), INFINITY, -0.0, 0);
		test2(atan2f, ldexpf(z, e), -INFINITY, (float)pi, FE_INEXACT);
		test2(atan2f, ldexpf(-z,e), -INFINITY, (float)-pi, FE_INEXACT);
#endif /* !__APPLE__ */
		test2(atan2f, INFINITY, ldexpf(z,e), (float)pi/2, FE_INEXACT);
		test2(atan2f, INFINITY, ldexpf(-z,e), (float)pi/2, FE_INEXACT);
		test2(atan2f, -INFINITY, ldexpf(z,e), (float)-pi/2,FE_INEXACT);
		test2(atan2f, -INFINITY, ldexpf(-z,e),(float)-pi/2,FE_INEXACT);
	}
	for (e = DBL_MIN_EXP - DBL_MANT_DIG; e <= DBL_MAX_EXP - 1; e++) {
		test2(atan2, ldexp(z, e), INFINITY, 0.0, 0);
		test2(atan2, ldexp(-z,e), INFINITY, -0.0, 0);
#if !__gnu_linux__
		test2(atan2, ldexp(z, e), -INFINITY, (double)pi, FE_INEXACT);
		test2(atan2, ldexp(-z,e), -INFINITY, (double)-pi, FE_INEXACT);
		test2(atan2, INFINITY, ldexp(z,e), (double)pi/2, FE_INEXACT);
		test2(atan2, INFINITY, ldexp(-z,e), (double)pi/2, FE_INEXACT);
		test2(atan2, -INFINITY, ldexp(z,e), (double)-pi/2,FE_INEXACT);
		test2(atan2, -INFINITY, ldexp(-z,e),(double)-pi/2,FE_INEXACT);
#endif /* !__gnu_linux__ */
	}
	for (e = LDBL_MIN_EXP - LDBL_MANT_DIG; e <= LDBL_MAX_EXP - 1; e++) {
		test2(atan2l, ldexpl(z, e), INFINITY, 0.0, 0);
		test2(atan2l, ldexpl(-z,e), INFINITY, -0.0, 0);
		test2(atan2l, ldexpl(z, e), -INFINITY, pi, FE_INEXACT);
		test2(atan2l, ldexpl(-z,e), -INFINITY, -pi, FE_INEXACT);
		test2(atan2l, INFINITY, ldexpl(z, e), pi / 2, FE_INEXACT);
		test2(atan2l, INFINITY, ldexpl(-z, e), pi / 2, FE_INEXACT);
		test2(atan2l, -INFINITY, ldexpl(z, e), -pi / 2, FE_INEXACT);
		test2(atan2l, -INFINITY, ldexpl(-z, e), -pi / 2, FE_INEXACT);
	}
}
NOMIPS16 int main ()
{
  float a, b;
  int i;

  /* cabs.eq.s */
  a = 12;
  b = -56;
  i = 0;
  if (__builtin_mips_cabs_eq_s(a, b) != i)
     abort ();

  /* cabs.eq.s */
  a = 12;
  b = -12;
  i = 1;
  if (__builtin_mips_cabs_eq_s(a, b) != i)
     abort ();

  /* Test all comparisons */
  a = 10.58;
  b = 567.345;

  i = test0 (a, b);
  if (i != 0)
    abort ();
  i = test1 (a, b);
  if (i != 0)
    abort ();
  i = test2 (a, b);
  if (i != 0)
    abort ();
  i = test3 (a, b);
  if (i != 0)
    abort ();
  i = test4 (a, b);
  if (i != 1)
    abort ();
  i = test5 (a, b);
  if (i != 1)
    abort ();
  i = test6 (a, b);
  if (i != 1)
    abort ();
  i = test7 (a, b);
  if (i != 1)
    abort ();
  i = test8 (a, b);
  if (i != 0)
    abort ();
  i = test9 (a, b);
  if (i != 0)
    abort ();
  i = test10 (a, b);
  if (i != 0)
    abort ();
  i = test11 (a, b);
  if (i != 0)
    abort ();
  i = test12 (a, b);
  if (i != 1)
    abort ();
  i = test13 (a, b);
  if (i != 1)
    abort ();
  i = test14 (a, b);
  if (i != 1)
    abort ();
  i = test15 (a, b);
  if (i != 1)
    abort ();

  /* Reversed arguments */
  i = test0 (b, a);
  if (i != 0)
    abort ();
  i = test1 (b, a);
  if (i != 0)
    abort ();
  i = test2 (b, a);
  if (i != 0)
    abort ();
  i = test3 (b, a);
  if (i != 0)
    abort ();
  i = test4 (b, a);
  if (i != 0)
    abort ();
  i = test5 (b, a);
  if (i != 0)
    abort ();
  i = test6 (b, a);
  if (i != 0)
    abort ();
  i = test7 (b, a);
  if (i != 0)
    abort ();
  i = test8 (b, a);
  if (i != 0)
    abort ();
  i = test9 (b, a);
  if (i != 0)
    abort ();
  i = test10 (b, a);
  if (i != 0)
    abort ();
  i = test11 (b, a);
  if (i != 0)
    abort ();
  i = test12 (b, a);
  if (i != 0)
    abort ();
  i = test13 (b, a);
  if (i != 0)
    abort ();
  i = test14 (b, a);
  if (i != 0)
    abort ();
  i = test15 (b, a);
  if (i != 0)
    abort ();

#ifndef __FAST_MATH__
  /* Test all comparisons */
  a = 1.0f/0.0f - 1.0f/0.0f; // QNaN
  b = 567.345;

  i = test0 (a, b);
  if (i != 0)
    abort ();
  i = test1 (a, b);
  if (i != 1)
    abort ();
  i = test2 (a, b);
  if (i != 0)
    abort ();
  i = test3 (a, b);
  if (i != 1)
    abort ();
  i = test4 (a, b);
  if (i != 0)
    abort ();
  i = test5 (a, b);
  if (i != 1)
    abort ();
  i = test6 (a, b);
  if (i != 0)
    abort ();
  i = test7 (a, b);
  if (i != 1)
    abort ();
  i = test8 (a, b);
  if (i != 0)
    abort ();
  i = test9 (a, b);
  if (i != 1)
    abort ();
  i = test10 (a, b);
  if (i != 0)
    abort ();
  i = test11 (a, b);
  if (i != 1)
    abort ();
  i = test12 (a, b);
  if (i != 0)
    abort ();
  i = test13 (a, b);
  if (i != 1)
    abort ();
  i = test14 (a, b);
  if (i != 0)
    abort ();
  i = test15 (a, b);
  if (i != 1)
    abort ();
#endif

  printf ("Test Passes\n");
  exit (0);
}
/*
 * Test inputs very close to 0.
 */
static void
test_tiny(void)
{
	float tiny = 0x1.23456p-120f;

#if !__gnu_linux__
	testall(asin, tiny, tiny, FE_INEXACT);
	testall(acos, tiny, pi / 2, FE_INEXACT);
	testall(atan, tiny, tiny, FE_INEXACT);

	testall(asin, -tiny, -tiny, FE_INEXACT);
	testall(acos, -tiny, pi / 2, FE_INEXACT);
	testall(atan, -tiny, -tiny, FE_INEXACT);
#endif /* !__gnu_linux__ */

	/* Test inputs to atan2() that would cause y/x to underflow. */
	test2(atan2f, 0x1.0p-100, 0x1.0p100, 0.0, FE_INEXACT | FE_UNDERFLOW);
	test2(atan2, 0x1.0p-1000, 0x1.0p1000, 0.0, FE_INEXACT | FE_UNDERFLOW);
	test2(atan2l, ldexpl(1.0, 100 - LDBL_MAX_EXP),
	      ldexpl(1.0, LDBL_MAX_EXP - 100), 0.0, FE_INEXACT | FE_UNDERFLOW);
	test2(atan2f, -0x1.0p-100, 0x1.0p100, -0.0, FE_INEXACT | FE_UNDERFLOW);
	test2(atan2, -0x1.0p-1000, 0x1.0p1000, -0.0, FE_INEXACT | FE_UNDERFLOW);
	test2(atan2l, -ldexpl(1.0, 100 - LDBL_MAX_EXP),
	      ldexpl(1.0, LDBL_MAX_EXP - 100), -0.0, FE_INEXACT | FE_UNDERFLOW);
#if !__APPLE__
	test2(atan2f, 0x1.0p-100, -0x1.0p100, (float)pi, FE_INEXACT);
#endif /* !__APPLE__ */
#if !__gnu_linux__
	test2(atan2, 0x1.0p-1000, -0x1.0p1000, (double)pi, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, ldexpl(1.0, 100 - LDBL_MAX_EXP),
	      -ldexpl(1.0, LDBL_MAX_EXP - 100), pi, FE_INEXACT);
#if !__APPLE__
	test2(atan2f, -0x1.0p-100, -0x1.0p100, (float)-pi, FE_INEXACT);
#endif /* !__APPLE__ */
#if !__gnu_linux__
	test2(atan2, -0x1.0p-1000, -0x1.0p1000, (double)-pi, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, -ldexpl(1.0, 100 - LDBL_MAX_EXP),
	      -ldexpl(1.0, LDBL_MAX_EXP - 100), -pi, FE_INEXACT);
}
Exemple #27
0
int main(void)
{
//	test1();
	test2();
	return 0;
}
/*
 * Test very large inputs to atan().
 */
static void
test_atan_huge(void)
{
	float huge = 0x1.23456p120;

#if !__APPLE__ && !__gnu_linux__
	testall(atan, huge, pi / 2, FE_INEXACT);
	testall(atan, -huge, -pi / 2, FE_INEXACT);
#endif /* !__APPLE__ && !__gnu_linux__ */

	/* Test inputs to atan2() that would cause y/x to overflow. */
	test2(atan2f, 0x1.0p100, 0x1.0p-100, (float)pi / 2, FE_INEXACT);
#if !__gnu_linux__
	test2(atan2, 0x1.0p1000, 0x1.0p-1000, (double)pi / 2, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, ldexpl(1.0, LDBL_MAX_EXP - 100),
	      ldexpl(1.0, 100 - LDBL_MAX_EXP), pi / 2, FE_INEXACT);
	test2(atan2f, -0x1.0p100, 0x1.0p-100, (float)-pi / 2, FE_INEXACT);
#if !__gnu_linux__
	test2(atan2, -0x1.0p1000, 0x1.0p-1000, (double)-pi / 2, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, -ldexpl(1.0, LDBL_MAX_EXP - 100),
	      ldexpl(1.0, 100 - LDBL_MAX_EXP), -pi / 2, FE_INEXACT);

#if !__gnu_linux__
	test2(atan2f, 0x1.0p100, -0x1.0p-100, (float)pi / 2, FE_INEXACT);
	test2(atan2, 0x1.0p1000, -0x1.0p-1000, (double)pi / 2, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, ldexpl(1.0, LDBL_MAX_EXP - 100),
	      -ldexpl(1.0, 100 - LDBL_MAX_EXP), pi / 2, FE_INEXACT);
#if !__gnu_linux__
	test2(atan2f, -0x1.0p100, -0x1.0p-100, (float)-pi / 2, FE_INEXACT);
	test2(atan2, -0x1.0p1000, -0x1.0p-1000, (double)-pi / 2, FE_INEXACT);
#endif /* !__gnu_linux__ */
	test2(atan2l, -ldexpl(1.0, LDBL_MAX_EXP - 100),
	      -ldexpl(1.0, 100 - LDBL_MAX_EXP), -pi / 2, FE_INEXACT);
}
Exemple #29
0
int main ( int /*argc*/, char * /*argv*/ [] ) {
//  Clamp takes a value and two "fenceposts", and brings the value "between" the fenceposts.

//  If the input value is "between" the fenceposts, then it is returned unchanged.
    std::cout << "Clamping   5 to between [1, 10] -> " << ba::clamp ( 5, 1, 10 ) << std::endl;

//  If the input value is out side the range of the fenceposts, it "brought into" range.
    std::cout << "Clamping  15 to between [1, 10] -> " << ba::clamp (  15, 1, 10 ) << std::endl;
    std::cout << "Clamping -15 to between [1, 10] -> " << ba::clamp ( -15, 1, 10 ) << std::endl;

//  It doesn't just work for ints
    std::cout << "Clamping 5.1 to between [1, 10] -> " << ba::clamp ( 5.1, 1.0, 10.0 ) << std::endl;

    {
        std::string one ( "Lower Bound" ), two ( "upper bound!" ), test1 ( "test#" ), test2 ( "#test" );
        std::cout << "Clamping '" << test1 << "' between ['" << one << "' and '" << two << "'] -> '" << 
            ba::clamp ( test1, one, two ) << "'" << std::endl;
        std::cout << "Clamping '" << test2 << "' between ['" << one << "' and '" << two << "'] -> '" << 
            ba::clamp ( test2, one, two ) << "'" << std::endl;
    //  There is also a predicate based version, if you want to compare objects in your own way
        std::cout << "Clamping '" << test1 << "' between ['" << one << "' and '" << two << "'] (comparing lengths) -> '" << 
            ba::clamp ( test1, one, two, compare_string_lengths ) << "'" << std::endl;
        std::cout << "Clamping '" << test2 << "' between ['" << one << "' and '" << two << "'] (comparing lengths) -> '" << 
            ba::clamp ( test2, one, two, compare_string_lengths ) << "'" << std::endl;
    
    }

//  Sometimes, though, you don't get quite what you expect
//  This is because the two double arguments get converted to int
    std::cout << "Somewhat unexpected: clamp ( 12, 14.7, 15.9 ) --> " << ba::clamp ( 12, 14.7, 15.9 ) << std::endl;
    std::cout << "Expected:     clamp ((double)12, 14.7, 15.9 ) --> " << ba::clamp ((double) 12, 14.7, 15.9 ) << std::endl;
    return 0;
    }
Exemple #30
0
__attribute__((noinline)) void test_b(B *bp) { test2 (bp); }