File: Platform.cpp

package info (click to toggle)
nsis 3.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,496 kB
  • sloc: cpp: 39,326; ansic: 27,284; python: 1,386; asm: 712; xml: 409; pascal: 231; makefile: 225; javascript: 67
file content (49 lines) | stat: -rwxr-xr-x 1,525 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
#include <cppunit/extensions/HelperMacros.h>
#include "../Platform.h"
#include "../tchar.h"
#include "../util.h"

class PlatformTest : public CppUnit::TestFixture {

  CPPUNIT_TEST_SUITE( PlatformTest );
  CPPUNIT_TEST( testCore );
  CPPUNIT_TEST( testCoreString );
  CPPUNIT_TEST( testCoreMath );
  CPPUNIT_TEST_SUITE_END();

public:
  void testCore() {
    CPPUNIT_ASSERT(sizeof(WINWCHAR) == 2);
    CPPUNIT_ASSERT(sizeof(wchar_t) >= sizeof(WINWCHAR));
  }

  void testCoreString() {
    TCHAR tbuf[42];

    CPPUNIT_ASSERT(3 == my_strncpy(tbuf, _T("abc"), 4) && tbuf[2] == _T('c') && tbuf[3] == _T('\0'));
    CPPUNIT_ASSERT(2 == my_strncpy(tbuf, _T("abc"), 3) && tbuf[1] == _T('b') && tbuf[2] == _T('\0'));
    CPPUNIT_ASSERT(ChIsHex('f')); CPPUNIT_ASSERT(ChIsHex('F'));
    CPPUNIT_ASSERT(ChIsHex(L'f')); CPPUNIT_ASSERT(ChIsHex(L'F'));

  }

  void testCoreMath() {

    unsigned int ut;
    CPPUNIT_ASSERT(ui_add(ut, 0, 0) != false);
    CPPUNIT_ASSERT(ui_add(ut, UINT_MAX, 0) != false && ut == UINT_MAX);
    CPPUNIT_ASSERT(ui_add(ut, UINT_MAX, 1) == false);

    int st;
    CPPUNIT_ASSERT(si_add(st, 0, 0) != false);
    CPPUNIT_ASSERT(si_add(st, INT_MAX,  0) != false && st == INT_MAX);
    CPPUNIT_ASSERT(si_add(st, INT_MAX,  1) == false);
    CPPUNIT_ASSERT(si_add(st, INT_MAX, -1) != false);
    CPPUNIT_ASSERT(si_add(st, INT_MIN,  0) != false);
    CPPUNIT_ASSERT(si_add(st, INT_MIN,  1) != false);
    CPPUNIT_ASSERT(si_add(st, INT_MIN, -1) == false);
  }

};

CPPUNIT_TEST_SUITE_REGISTRATION( PlatformTest );