1 // ============================================================================
7 // This simple test exercises and illustrates use of ACE value-added
11 // Steve Huston <shuston@riverace.com>
13 // ============================================================================
15 #include "test_config.h"
18 #include "ace/OS_NS_stdlib.h"
23 u_long values
[] = {1, 2, 4, 8, 1048576};
24 u_long results
[] = {0, 1, 2, 3, 20};
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
]));
46 // Check if ACE::debug() is by default false when no ACE_DEBUG environment variable
48 const char* debug
= ACE_OS::getenv ("ACE_DEBUG");
52 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ACE::debug() returns true.\n")));
57 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ACE::debug() returns false.\n")));
63 // Test ACE::execname to be sure it finds .exe without regard to case.
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
);
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
);
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"),
100 delete [] const_cast<ACE_TCHAR
*> (newname
);
101 #endif /* ACE_WIN32 */
108 run_main (int, ACE_TCHAR
*[])
110 ACE_START_TEST (ACE_TEXT ("ACE_Test"));
115 if ((result
= execname_test ()) != 0)
118 if ((result
= log2_test ()) != 0)
121 if ((result
= ace_debug_test ()) != 0)