@@ -26,7 +26,7 @@ bool RunDecodeLatin1(Environment* env,
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | |
29 | | - *result = try_catch.Exception(); |
| 29 | + *result = args[0]; |
30 | 30 | return true; |
31 | 31 | } |
32 | 32 | |
@@ -151,5 +151,26 @@ TEST_F(EncodingBindingTest, DecodeLatin1_BOMPresent) {
|
151 | 151 | EXPECT_STREQ(*utf8_result, "Áéó"); |
152 | 152 | } |
153 | 153 | |
| 154 | +TEST_F(EncodingBindingTest, DecodeLatin1_ReturnsString) { |
| 155 | + Environment* env = CreateEnvironment(); |
| 156 | + Isolate* isolate = env->isolate(); |
| 157 | + HandleScope handle_scope(isolate); |
| 158 | + |
| 159 | +const uint8_t latin1_data[] = {0xC1, 0xE9, 0xF3}; |
| 160 | + Local<ArrayBuffer> ab = ArrayBuffer::New(isolate, sizeof(latin1_data)); |
| 161 | +memcpy(ab->GetBackingStore()->Data(), latin1_data, sizeof(latin1_data)); |
| 162 | + |
| 163 | + Local<Uint8Array> array = Uint8Array::New(ab, 0, sizeof(latin1_data)); |
| 164 | + Local<Value> args[] = {array}; |
| 165 | + |
| 166 | + Local<Value> result; |
| 167 | +ASSERT_TRUE(RunDecodeLatin1(env, args, false, false, &result)); |
| 168 | + |
| 169 | +ASSERT_TRUE(result->IsString()); |
| 170 | + |
| 171 | + String::Utf8Value utf8_result(isolate, result); |
| 172 | +EXPECT_STREQ(*utf8_result, "Áéó"); |
| 173 | +} |
| 174 | + |
154 | 175 | } // namespace encoding_binding |
155 | 176 | } // namespace node |