/[jscoverage]/trunk/tests/encodings.c
ViewVC logotype

Diff of /trunk/tests/encodings.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 205 by siliconforks, Fri Oct 3 02:22:22 2008 UTC revision 221 by siliconforks, Fri Oct 3 02:27:43 2008 UTC
# Line 81  Line 81 
81    
82    free(characters);    free(characters);
83    
84      uint8_t utf16be[] = {
85        0, 'e',
86        0, 0xe8,
87        0, 0xe9,
88        0, 0xea,
89      };
90    
91      result = jscoverage_bytes_to_characters("UTF-16BE", utf16be, 8, &characters, &num_characters);
92    
93      assert(result == 0);
94      assert(num_characters == 4);
95      assert(characters[0] == 'e');
96      assert(characters[1] == 0xe8);
97      assert(characters[2] == 0xe9);
98      assert(characters[3] == 0xea);
99    
100      free(characters);
101    
102      uint8_t utf16be_with_bom[] = {
103        0xfe, 0xff,
104        0, 'e',
105        0, 0xe8,
106        0, 0xe9,
107        0, 0xea,
108      };
109    
110      result = jscoverage_bytes_to_characters("UTF-16BE", utf16be_with_bom, 10, &characters, &num_characters);
111    
112      assert(result == 0);
113      assert(num_characters == 4);
114      assert(characters[0] == 'e');
115      assert(characters[1] == 0xe8);
116      assert(characters[2] == 0xe9);
117      assert(characters[3] == 0xea);
118    
119      free(characters);
120    
121      uint8_t utf16le[] = {
122        'e', 0,
123        0xe8, 0,
124        0xe9, 0,
125        0xea, 0,
126      };
127    
128      result = jscoverage_bytes_to_characters("UTF-16LE", utf16le, 8, &characters, &num_characters);
129    
130      assert(result == 0);
131      assert(num_characters == 4);
132      assert(characters[0] == 'e');
133      assert(characters[1] == 0xe8);
134      assert(characters[2] == 0xe9);
135      assert(characters[3] == 0xea);
136    
137      free(characters);
138    
139      uint8_t utf16le_with_bom[] = {
140        0xff, 0xfe,
141        'e', 0,
142        0xe8, 0,
143        0xe9, 0,
144        0xea, 0,
145      };
146    
147      result = jscoverage_bytes_to_characters("UTF-16LE", utf16le_with_bom, 10, &characters, &num_characters);
148    
149      assert(result == 0);
150      assert(num_characters == 4);
151      assert(characters[0] == 'e');
152      assert(characters[1] == 0xe8);
153      assert(characters[2] == 0xe9);
154      assert(characters[3] == 0xea);
155    
156      free(characters);
157    
158      /* bogus encoding */
159      uint8_t bogus[] = {'b', 'o', 'g', 'u', 's'};
160    
161      result = jscoverage_bytes_to_characters("BOGUS", bogus, 5, &characters, &num_characters);
162    
163      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
164    
165      /* malformed */
166      uint8_t malformed_ascii[] = {
167        'e',
168        0xe8,
169        0xe9,
170        0xea,
171      };
172    
173      result = jscoverage_bytes_to_characters("US-ASCII", malformed_ascii, 4, &characters, &num_characters);
174    
175      assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE);
176    
177    return 0;    return 0;
178  }  }

Legend:
Removed from v.205  
changed lines
  Added in v.221

  ViewVC Help
Powered by ViewVC 1.1.24