Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / tests / ACE_Test.cpp
blob95d55bdd56ab5b2bb57d45257083bba78a29f742
1 // ============================================================================
2 //
3 // = LIBRARY
4 // tests
5 //
6 // = DESCRIPTION
7 // This simple test exercises and illustrates use of ACE value-added
8 // functions.
9 //
10 // = AUTHOR
11 // Steve Huston <shuston@riverace.com>
13 // ============================================================================
15 #include "test_config.h"
17 #include "ace/ACE.h"
18 #include "ace/OS_NS_stdlib.h"
20 int
21 log2_test ()
23 u_long values[] = {1, 2, 4, 8, 1048576};
24 u_long results[] = {0, 1, 2, 3, 20};
25 u_long result = 0;
26 int error_count = 0;
28 for (size_t i = 0 ; i < sizeof (values) / sizeof (u_long) ; i++)
30 result = ACE::log2(values [i]);
31 if (result != results [i])
33 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Log2 error: input %d, output %d, expected %d\n"), values [i], result, results [i]));
34 error_count++;
38 return error_count;
41 int
42 ace_debug_test ()
44 int test_status = 0;
46 // Check if ACE::debug() is by default false when no ACE_DEBUG environment variable
47 // is there
48 const char* debug = ACE_OS::getenv ("ACE_DEBUG");
49 if (debug == 0)
51 if (ACE::debug())
52 ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE::debug() returns true.\n")));
54 else
56 if (!ACE::debug())
57 ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE::debug() returns false.\n")));
60 return test_status;
63 // Test ACE::execname to be sure it finds .exe without regard to case.
64 int
65 execname_test ()
67 int error_count = 0;
69 // This test is only interesting on Win32
70 #if defined (ACE_WIN32)
71 const ACE_TCHAR *newname;
72 const ACE_TCHAR *prog1 = ACE_TEXT ("myprog.exe");
73 const ACE_TCHAR *prog2 = ACE_TEXT ("myprog.EXE");
74 const ACE_TCHAR *prog3 = ACE_TEXT ("myprog");
76 newname = ACE::execname (prog1);
77 if (newname != prog1) // Didn't find .exe correctly
79 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Name %s, not %s\n"), newname, prog1));
80 delete [] const_cast<ACE_TCHAR *> (newname);
81 ++error_count;
84 newname = ACE::execname (prog2);
85 if (newname != prog2) // Didn't find .exe correctly
87 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Name %s, not %s\n"), newname, prog2));
88 delete [] const_cast<ACE_TCHAR *> (newname);
89 ++error_count;
92 newname = ACE::execname (prog3);
93 if (newname == prog3) // Thought the name didn't need .exe
95 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Says .exe not needed for %s\n"),
96 newname));
97 ++error_count;
99 else
100 delete [] const_cast<ACE_TCHAR *> (newname);
101 #endif /* ACE_WIN32 */
103 return error_count;
108 run_main (int, ACE_TCHAR *[])
110 ACE_START_TEST (ACE_TEXT ("ACE_Test"));
112 int status = 0;
113 int result;
115 if ((result = execname_test ()) != 0)
116 status = result;
118 if ((result = log2_test ()) != 0)
119 status = result;
121 if ((result = ace_debug_test ()) != 0)
122 status = result;
124 ACE_END_TEST;
125 return status;