aboutsummaryrefslogtreecommitdiff
path: root/src/tests/variant.cpp
blob: 79893c066fdfca08c393df3f1c40b163a3e9252f (plain)
1
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
44
45
46
47
48
49
50
51
52
/*
 * Copyright (C) 2007-2010 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include <bu/sio.h>
#include <bu/variant.h>
#include <bu/list.h>

using namespace Bu;

Variant getThing( int i )
{
	Variant v;
	switch( i )
	{
	case 0:
		v = 45;
		break;

	case 1:
		v = true;
		break;

	case 2:
		v = List<int>(5).append(10).append(15);
		break;
	}

	return v;
}

int main()
{
	Variant a;
	Variant b;
	Variant c;

	a = getThing( 0 );
	b = getThing( 1 );
	c = getThing( 2 );

	sio << "a = " << a << " or " << (int)a << sio.nl
		<< "b = " << b << " or " << b.toString() << sio.nl
		<< "c = " << c << " or " << c.toString() << sio.nl
		<< sio.nl;

	return 0;
}