1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> |
---|
5 | // This program is free software; you can redistribute it and/or |
---|
6 | // modify it under the terms of the Do What The Fuck You Want To |
---|
7 | // Public License, Version 2, as published by Sam Hocevar. See |
---|
8 | // http://sam.zoy.org/projects/COPYING.WTFPL for more details. |
---|
9 | // |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include "core.h" |
---|
16 | #include "lol/unit.h" |
---|
17 | |
---|
18 | namespace lol |
---|
19 | { |
---|
20 | |
---|
21 | LOLUNIT_FIXTURE(ArrayTest) |
---|
22 | { |
---|
23 | void SetUp() {} |
---|
24 | |
---|
25 | void TearDown() {} |
---|
26 | |
---|
27 | LOLUNIT_TEST(ArrayFill) |
---|
28 | { |
---|
29 | Array<int> a; |
---|
30 | a.Append(0); |
---|
31 | a.Append(1); |
---|
32 | a.Append(2); |
---|
33 | a.Append(3); |
---|
34 | |
---|
35 | LOLUNIT_ASSERT_EQUAL(a[0], 0); |
---|
36 | LOLUNIT_ASSERT_EQUAL(a[1], 1); |
---|
37 | LOLUNIT_ASSERT_EQUAL(a[2], 2); |
---|
38 | LOLUNIT_ASSERT_EQUAL(a[3], 3); |
---|
39 | } |
---|
40 | |
---|
41 | LOLUNIT_TEST(ArrayCopy) |
---|
42 | { |
---|
43 | Array<int> a; |
---|
44 | a.Append(0); |
---|
45 | a.Append(1); |
---|
46 | a.Append(2); |
---|
47 | a.Append(3); |
---|
48 | |
---|
49 | Array<int> b = a; |
---|
50 | |
---|
51 | LOLUNIT_ASSERT_EQUAL(b[0], 0); |
---|
52 | LOLUNIT_ASSERT_EQUAL(b[1], 1); |
---|
53 | LOLUNIT_ASSERT_EQUAL(b[2], 2); |
---|
54 | LOLUNIT_ASSERT_EQUAL(b[3], 3); |
---|
55 | } |
---|
56 | |
---|
57 | LOLUNIT_TEST(EightElements) |
---|
58 | { |
---|
59 | Array<int, long, float, double, unsigned, char, bool, void *> a; |
---|
60 | a.Append(1, 2, 3.f, 4.0, 5, 'a', true, 0); |
---|
61 | |
---|
62 | LOLUNIT_ASSERT_EQUAL(a[0].m1, 1); |
---|
63 | LOLUNIT_ASSERT_EQUAL(a[0].m2, 2); |
---|
64 | LOLUNIT_ASSERT_EQUAL(a[0].m3, 3.f); |
---|
65 | LOLUNIT_ASSERT_EQUAL(a[0].m4, 4.0); |
---|
66 | LOLUNIT_ASSERT_EQUAL(a[0].m5, 5); |
---|
67 | LOLUNIT_ASSERT_EQUAL(a[0].m6, 'a'); |
---|
68 | LOLUNIT_ASSERT_EQUAL(a[0].m7, true); |
---|
69 | LOLUNIT_ASSERT_EQUAL(a[0].m8, 0); |
---|
70 | } |
---|
71 | }; |
---|
72 | |
---|
73 | } /* namespace lol */ |
---|
74 | |
---|