etc
Check-in [ddf80e8868]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:some cleanup
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ddf80e8868ea989ed39be167348f447917952338
User & Date: alzwded 2014-04-12 11:55:30
Context
2014-04-12
12:28
update readme check-in: 9f3e25f774 user: alzwded tags: trunk, test-tag
11:55
some cleanup check-in: ddf80e8868 user: alzwded tags: trunk
11:42
moved test related macros to test.hxx check-in: 5326ee38a0 user: alzwded tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to t2048/Makefile.

32
33
34
35
36
37
38
39
	sed 2048.cpp -e '/TALK/d' > 2048-cleaned.cpp

test.out: pack.cpp
	g++ -g --std=gnu++11 -DTEST_PACK -o test.out pack.cpp
	./run-tests.csh

clean:
	rm -f a.out 2048-cleaned.cpp *.o 2048.exe *.obj *.dll







|
32
33
34
35
36
37
38
39
	sed 2048.cpp -e '/TALK/d' > 2048-cleaned.cpp

test.out: pack.cpp
	g++ -g --std=gnu++11 -DTEST_PACK -o test.out pack.cpp
	./run-tests.csh

clean:
	rm -f a.out 2048-cleaned.cpp *.o 2048.exe *.obj *.dll *.out

Changes to t2048/run-tests.csh.

1
2
3
4
5
6
7
#!/bin/csh

set tests=`./test.out -l`

foreach test ($tests)
    ./test.out $test || echo "FAIL"
end





|

1
2
3
4
5
6
7
#!/bin/csh

set tests=`./test.out -l`

foreach test ($tests)
    ./test.out $test || echo "$test FAILED"
end

Changes to t2048/test.hxx.

2
3
4
5
6
7
8




























9
10
11
12
13
14
15
..
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
53
#define TEST_HXX

#include <cassert>
#include <cstring>

/*
   My nice little test bed header.




























*/

#define TEST_NELEMENTS(A) ( sizeof(A) / sizeof(A[0]) )

#define TEST_BUNDLE_BEGIN(BUNDLE_NAME) \
static struct { \
    const char* name; \
................................................................................
} BUNDLE_NAME[] =

#define TEST_BEGIN(NAME) \
{ #NAME, [&]() { \
    printf("%s: ", #NAME);

#define TEST_END(NAME) \
    printf("OK\n"); \
    return 0; \
               }},

#define TEST_BUNDLE_END(BUNDLE_NAME)

#define NO_TEST_FOUND false
#define TEST_MAIN(BUNDLE_NAME, ret, argc, argv) \
do { \
    size_t i = 0; \
    assert(argc == 2); \
    if(argv[1][0] == '-' && argv[1][1] == 'l') { \
        for(; i < TEST_NELEMENTS(BUNDLE_NAME); ++i) { \
            printf("%s ", BUNDLE_NAME[i].name); \
................................................................................
        } \
        printf("\n"); \
        ret = 0; \
        break; \
    } \
    for(; i < TEST_NELEMENTS(BUNDLE_NAME); ++i) { \
        if(strcmp(argv[1], BUNDLE_NAME[i].name) == 0) { \
            return BUNDLE_NAME[i].fn(); \



        } \
    } \
    assert(NO_TEST_FOUND); \
    ret = 255; \
    break; \
} while(0)

#endif







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<





<







 







|
>
>
>


<
<
<



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
45
46
47
48
49
50
51

52
53
54
55
56

57
58
59
60
61
62
63
..
64
65
66
67
68
69
70
71
72
73
74
75
76



77
78
79
#define TEST_HXX

#include <cassert>
#include <cstring>

/*
   My nice little test bed header.

Usage:
    // define a test bundle
    TEST_BUNDLE_BEGIN(BundleName)
    {
        TEST_BEGIN(TestingAssertTrueDoesntFail) {
            assert(true);
        } TEST_END(TestingAssertTrueDoesntFail)

        TEST_BEGIN(TestingAnIntegerEqualsItself) {
            int anInteger = 42;
            assert(anInteger == anInteger);
            assert(anInteger == 42);
        } TEST_END(TestingAnIntegerEqualsItself)

        TEST_BEGIN(FailWorks) {
            return 255;
        } TEST_END(FailWorks)
    }
    TEST_BUNDLE_END(BundleName);

    // run the bundle
    int main(int argc, char* argv)
    {
        int testResult(0);
        TEST_MAIN(BundleName, testResult, argc, argv);
        return testResult;
    }
*/

#define TEST_NELEMENTS(A) ( sizeof(A) / sizeof(A[0]) )

#define TEST_BUNDLE_BEGIN(BUNDLE_NAME) \
static struct { \
    const char* name; \
................................................................................
} BUNDLE_NAME[] =

#define TEST_BEGIN(NAME) \
{ #NAME, [&]() { \
    printf("%s: ", #NAME);

#define TEST_END(NAME) \

    return 0; \
               }},

#define TEST_BUNDLE_END(BUNDLE_NAME)


#define TEST_MAIN(BUNDLE_NAME, ret, argc, argv) \
do { \
    size_t i = 0; \
    assert(argc == 2); \
    if(argv[1][0] == '-' && argv[1][1] == 'l') { \
        for(; i < TEST_NELEMENTS(BUNDLE_NAME); ++i) { \
            printf("%s ", BUNDLE_NAME[i].name); \
................................................................................
        } \
        printf("\n"); \
        ret = 0; \
        break; \
    } \
    for(; i < TEST_NELEMENTS(BUNDLE_NAME); ++i) { \
        if(strcmp(argv[1], BUNDLE_NAME[i].name) == 0) { \
            int retCode = BUNDLE_NAME[i].fn(); \
            if(retCode == 0) printf("OK\n"); \
            else printf("Fail\n"); \
            return retCode; \
        } \
    } \



} while(0)

#endif