| 106 | } |
| 107 | |
| 108 | Value CreateBufferCopy(const CallbackInfo& info) { |
| 109 | InitData(testData, testLength); |
| 110 | |
| 111 | Buffer<uint16_t> buffer = |
| 112 | Buffer<uint16_t>::Copy(info.Env(), testData, testLength); |
| 113 | |
| 114 | if (buffer.Length() != testLength) { |
| 115 | Error::New(info.Env(), "Incorrect buffer length.") |
| 116 | .ThrowAsJavaScriptException(); |
| 117 | return Value(); |
| 118 | } |
| 119 | |
| 120 | if (buffer.Data() == testData) { |
| 121 | Error::New(info.Env(), "Copy should have different memory.") |
| 122 | .ThrowAsJavaScriptException(); |
| 123 | return Value(); |
| 124 | } |
| 125 | |
| 126 | if (!VerifyData(buffer.Data(), buffer.Length())) { |
| 127 | Error::New(info.Env(), "Copy data is incorrect.") |
| 128 | .ThrowAsJavaScriptException(); |
| 129 | return Value(); |
| 130 | } |
| 131 | |
| 132 | return buffer; |
| 133 | } |
| 134 | |
| 135 | #include "buffer_new_or_copy-inl.h" |
| 136 |
nothing calls this directly
no test coverage detected