diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tests/variant.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/variant.cpp b/src/tests/variant.cpp new file mode 100644 index 0000000..a0ac1f2 --- /dev/null +++ b/src/tests/variant.cpp | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #include <bu/sio.h> | ||
| 2 | #include <bu/variant.h> | ||
| 3 | #include <bu/list.h> | ||
| 4 | |||
| 5 | using namespace Bu; | ||
| 6 | |||
| 7 | Variant getThing( int i ) | ||
| 8 | { | ||
| 9 | Variant v; | ||
| 10 | switch( i ) | ||
| 11 | { | ||
| 12 | case 0: | ||
| 13 | v = 45; | ||
| 14 | break; | ||
| 15 | |||
| 16 | case 1: | ||
| 17 | v = true; | ||
| 18 | break; | ||
| 19 | |||
| 20 | case 2: | ||
| 21 | v = List<int>(5).append(10).append(15); | ||
| 22 | break; | ||
| 23 | } | ||
| 24 | |||
| 25 | return v; | ||
| 26 | } | ||
| 27 | |||
| 28 | int main() | ||
| 29 | { | ||
| 30 | Variant a; | ||
| 31 | Variant b; | ||
| 32 | Variant c; | ||
| 33 | |||
| 34 | a = getThing( 0 ); | ||
| 35 | b = getThing( 1 ); | ||
| 36 | c = getThing( 2 ); | ||
| 37 | |||
| 38 | sio << "a = " << a << " or " << (int)a << sio.nl | ||
| 39 | << "b = " << b << " or " << b.toString() << sio.nl | ||
| 40 | << "c = " << c << " or " << c.toString() << sio.nl | ||
| 41 | << sio.nl; | ||
| 42 | |||
| 43 | return 0; | ||
| 44 | } | ||
| 45 | |||
