File: null_comparison.cpp

package info (click to toggle)
mysql%2B%2B 3.0.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 10,328 kB
  • ctags: 9,487
  • sloc: cpp: 33,486; sh: 3,091; perl: 809; makefile: 683
file content (68 lines) | stat: -rw-r--r-- 2,256 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/***********************************************************************
 test/null_comparison.cpp - Tests that Null<T> and null_type comparison
 	operators and SSQLS comparison functions work correctly.

 Copyright (c) 2008 by Educational Technology Resources, Inc.
 Others may also hold copyrights on code in this file.  See the
 CREDITS file in the top directory of the distribution for details.

 This file is part of MySQL++.

 MySQL++ is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
 by the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.

 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with MySQL++; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 USA
***********************************************************************/

#include <mysql++.h>
#include <ssqls.h>

#include <iostream>

sql_create_1(ssqls, 1, 0,
		mysqlpp::Null<int>, a_column);

int
main()
{
	mysqlpp::Null<int> null_int = mysqlpp::null;
	mysqlpp::Null<int> non_null_int = 42;
	if (	!(null_int == non_null_int) &&
			(null_int != non_null_int) &&
			(null_int < non_null_int) &&
			!(non_null_int == null_int) &&
			(non_null_int != null_int) &&
			!(non_null_int < null_int) &&
			(null_int == mysqlpp::null) &&
			!(null_int != mysqlpp::null) &&
			(non_null_int != mysqlpp::null) &&
			!(non_null_int == mysqlpp::null) &&
			(mysqlpp::sql_cmp(null_int, null_int) == 0) &&
			(mysqlpp::sql_cmp(null_int, non_null_int) < 0) &&
			(mysqlpp::sql_cmp(non_null_int, null_int) > 0)) {
		ssqls foo(null_int), bar(non_null_int);
		if ((foo < bar) && (foo != bar) && !(bar < foo) && !(foo == bar)) {
			return 0;
		}
		else {
			std::cerr << "SSQLS comparison gave unexpected result" <<
					std::endl;
			return 1;
		}
	}
	else {
		std::cerr << "Null comparison gave unexpected result" << std::endl;
		return 1;
	}
}