/[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 313 by siliconforks, Mon Oct 13 07:19:42 2008 UTC revision 314 by siliconforks, Mon Oct 13 17:52:41 2008 UTC
# Line 43  Line 43 
43    
44    result = jscoverage_bytes_to_characters("UTF-8", utf8, 7, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-8", utf8, 7, &characters, &num_characters);
45    
46    #if HAVE_ICONV || HAVE_MULTIBYTETOWIDECHAR
47    assert(result == 0);    assert(result == 0);
48    assert(num_characters == 4);    assert(num_characters == 4);
49    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 51  Line 52 
52    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
53    
54    free(characters);    free(characters);
55    #else
56      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
57    #endif
58    
59    /*    /*
60    BOM is 0xfeff    BOM is 0xfeff
# Line 74  Line 78 
78    
79    result = jscoverage_bytes_to_characters("UTF-8", utf8_with_bom, 10, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-8", utf8_with_bom, 10, &characters, &num_characters);
80    
81    #if HAVE_ICONV || HAVE_MULTIBYTETOWIDECHAR
82    assert(result == 0);    assert(result == 0);
83    assert(num_characters == 4);    assert(num_characters == 4);
84    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 82  Line 87 
87    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
88    
89    free(characters);    free(characters);
90    #else
91      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
92    #endif
93    
 #ifdef HAVE_ICONV  
94    uint8_t utf16be[] = {    uint8_t utf16be[] = {
95      0, 'e',      0, 'e',
96      0, 0xe8,      0, 0xe8,
# Line 93  Line 100 
100    
101    result = jscoverage_bytes_to_characters("UTF-16BE", utf16be, 8, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-16BE", utf16be, 8, &characters, &num_characters);
102    
103    #ifdef HAVE_ICONV
104    assert(result == 0);    assert(result == 0);
105    assert(num_characters == 4);    assert(num_characters == 4);
106    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 101  Line 109 
109    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
110    
111    free(characters);    free(characters);
112    #else
113      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
114    #endif
115    
116    uint8_t utf16be_with_bom[] = {    uint8_t utf16be_with_bom[] = {
117      0xfe, 0xff,      0xfe, 0xff,
# Line 112  Line 123 
123    
124    result = jscoverage_bytes_to_characters("UTF-16BE", utf16be_with_bom, 10, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-16BE", utf16be_with_bom, 10, &characters, &num_characters);
125    
126    #ifdef HAVE_ICONV
127    assert(result == 0);    assert(result == 0);
128    assert(num_characters == 4);    assert(num_characters == 4);
129    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 120  Line 132 
132    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
133    
134    free(characters);    free(characters);
135    #else
136      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
137    #endif
138    
139    uint8_t utf16le[] = {    uint8_t utf16le[] = {
140      'e', 0,      'e', 0,
# Line 130  Line 145 
145    
146    result = jscoverage_bytes_to_characters("UTF-16LE", utf16le, 8, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-16LE", utf16le, 8, &characters, &num_characters);
147    
148    #ifdef HAVE_ICONV
149    assert(result == 0);    assert(result == 0);
150    assert(num_characters == 4);    assert(num_characters == 4);
151    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 138  Line 154 
154    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
155    
156    free(characters);    free(characters);
157    #else
158      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
159    #endif
160    
161    uint8_t utf16le_with_bom[] = {    uint8_t utf16le_with_bom[] = {
162      0xff, 0xfe,      0xff, 0xfe,
# Line 149  Line 168 
168    
169    result = jscoverage_bytes_to_characters("UTF-16LE", utf16le_with_bom, 10, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-16LE", utf16le_with_bom, 10, &characters, &num_characters);
170    
171    #ifdef HAVE_ICONV
172    assert(result == 0);    assert(result == 0);
173    assert(num_characters == 4);    assert(num_characters == 4);
174    assert(characters[0] == 'e');    assert(characters[0] == 'e');
# Line 157  Line 177 
177    assert(characters[3] == 0xea);    assert(characters[3] == 0xea);
178    
179    free(characters);    free(characters);
180    #else
181      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
182  #endif  #endif
183    
184    /* bogus encoding */    /* bogus encoding */
# Line 191  Line 213 
213    
214    result = jscoverage_bytes_to_characters("UTF-8", malformed_utf8, 4, &characters, &num_characters);    result = jscoverage_bytes_to_characters("UTF-8", malformed_utf8, 4, &characters, &num_characters);
215    
216    #if HAVE_ICONV || HAVE_MULTIBYTETOWIDECHAR
217    assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE);    assert(result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE);
218    #else
219      assert(result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED);
220    #endif
221    
222    return 0;    return 0;
223  }  }

Legend:
Removed from v.313  
changed lines
  Added in v.314

  ViewVC Help
Powered by ViewVC 1.1.24