Mercurial > hg > CbC > CbC_gcc
comparison gcc/hash-set-tests.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Unit tests for hash-set.h. | |
2 Copyright (C) 2015-2017 Free Software Foundation, Inc. | |
3 | |
4 This file is part of GCC. | |
5 | |
6 GCC is free software; you can redistribute it and/or modify it under | |
7 the terms of the GNU General Public License as published by the Free | |
8 Software Foundation; either version 3, or (at your option) any later | |
9 version. | |
10 | |
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GCC; see the file COPYING3. If not see | |
18 <http://www.gnu.org/licenses/>. */ | |
19 | |
20 #include "config.h" | |
21 #include "system.h" | |
22 #include "coretypes.h" | |
23 #include "tm.h" | |
24 #include "opts.h" | |
25 #include "hash-set.h" | |
26 #include "selftest.h" | |
27 | |
28 #if CHECKING_P | |
29 | |
30 namespace selftest { | |
31 | |
32 /* Construct a hash_set <const char *> and verify that various operations | |
33 work correctly. */ | |
34 | |
35 static void | |
36 test_set_of_strings () | |
37 { | |
38 hash_set <const char *> s; | |
39 ASSERT_EQ (0, s.elements ()); | |
40 | |
41 const char *red = "red"; | |
42 const char *green = "green"; | |
43 const char *blue = "blue"; | |
44 | |
45 ASSERT_EQ (false, s.contains (red)); | |
46 | |
47 /* Populate the hash_set. */ | |
48 ASSERT_EQ (false, s.add (red)); | |
49 ASSERT_EQ (false, s.add (green)); | |
50 ASSERT_EQ (false, s.add (blue)); | |
51 | |
52 /* Verify that the values are now within the set. */ | |
53 ASSERT_EQ (true, s.contains (red)); | |
54 ASSERT_EQ (true, s.contains (green)); | |
55 ASSERT_EQ (true, s.contains (blue)); | |
56 } | |
57 | |
58 /* Run all of the selftests within this file. */ | |
59 | |
60 void | |
61 hash_set_tests_c_tests () | |
62 { | |
63 test_set_of_strings (); | |
64 } | |
65 | |
66 } // namespace selftest | |
67 | |
68 #endif /* #if CHECKING_P */ |