File: char_strings_runme.1.d

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (151 lines) | stat: -rw-r--r-- 4,992 bytes parent folder | download | duplicates (12)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
module char_strings_runme;

import tango.text.convert.Integer;
import char_strings.char_strings;

const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
const char[] OTHERLAND_MSG = "Little message from the safe world.";

void main() {
  const uint count = 10000;
  uint i = 0;

  // get functions
  for (i=0; i<count; i++) {
    char[] str = GetCharHeapString();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char get 1 failed, iteration " ~ toString(i));
    DeleteCharHeapString();
  }

  for (i=0; i<count; i++) {
    char[] str = GetConstCharProgramCodeString();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char get 2 failed, iteration " ~ toString(i));
    DeleteCharHeapString();
  }

  for (i=0; i<count; i++) {
    char[] str = GetCharStaticString();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char get 3 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    char[] str = GetCharStaticStringFixed();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char get 4 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    char[] str = GetConstCharStaticStringFixed();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char get 5 failed, iteration " ~ toString(i));
  }

  // set functions
  for (i=0; i<count; i++) {
    if (!SetCharHeapString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 1 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetCharStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 2 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetCharArrayStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 3 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetConstCharHeapString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 4 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetConstCharStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 5 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetConstCharArrayStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 6 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetCharConstStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 7 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetConstCharConstStaticString(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char set 8 failed, iteration " ~ toString(i));
  }

  // get set function
  for (i=0; i<count*10; i++) {
    char[] ping = OTHERLAND_MSG ~ toString(i);
    char[] pong = CharPingPong(ping);
    if (ping != pong)
      throw new Exception("Test PingPong 1 failed.\nExpected:" ~ ping ~ "\nReceived:" ~ pong);
  }

  // variables
  for (i=0; i<count; i++) {
    global_char = OTHERLAND_MSG ~ toString(i);
    if (global_char != OTHERLAND_MSG ~ toString(i))
      throw new Exception("Test variables 1 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    global_char_array1 = OTHERLAND_MSG ~ toString(i);
    if (global_char_array1 != OTHERLAND_MSG ~ toString(i))
      throw new Exception("Test variables 2 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    global_char_array2 = OTHERLAND_MSG ~ toString(i);
    if (global_char_array2 != OTHERLAND_MSG ~ toString(i))
      throw new Exception("Test variables 3 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (global_const_char != CPLUSPLUS_MSG)
      throw new Exception("Test variables 4 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (global_const_char_array1 != CPLUSPLUS_MSG)
      throw new Exception("Test variables 5 failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (global_const_char_array2 != CPLUSPLUS_MSG)
      throw new Exception("Test variables 6 failed, iteration " ~ toString(i));
  }

  // char *& tests
  for (i=0; i<count; i++) {
    char[] str = GetCharPointerRef();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test char pointer ref get failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetCharPointerRef(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test char pointer ref set failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    char[] str = GetConstCharPointerRef();
    if (str != CPLUSPLUS_MSG)
      throw new Exception("Test const char pointer ref get failed, iteration " ~ toString(i));
  }

  for (i=0; i<count; i++) {
    if (!SetConstCharPointerRef(OTHERLAND_MSG ~ toString(i), i))
      throw new Exception("Test const char pointer ref set failed, iteration " ~ toString(i));
  }
}