2020-06-18 00:18:03 +03:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
#include "pch.h"
|
2021-04-09 09:44:51 +03:00
|
|
|
#include <JSI/ChakraRuntimeArgs.h>
|
|
|
|
#include <JSI/ChakraRuntimeFactory.h>
|
2020-06-18 00:18:03 +03:00
|
|
|
#include <JsiReader.h>
|
|
|
|
#include <JsiWriter.h>
|
|
|
|
#include "CommonReaderTest.h"
|
|
|
|
|
|
|
|
namespace winrt::Microsoft::ReactNative {
|
|
|
|
|
|
|
|
TEST_CLASS (JsiArgumentReaderTest) {
|
2021-04-09 09:44:51 +03:00
|
|
|
std::unique_ptr<::facebook::jsi::Runtime> m_runtime;
|
2020-06-18 00:18:03 +03:00
|
|
|
|
2021-04-09 09:44:51 +03:00
|
|
|
JsiArgumentReaderTest() : m_runtime(::Microsoft::JSI::makeChakraRuntime(::Microsoft::JSI::ChakraRuntimeArgs{})) {}
|
2020-06-18 00:18:03 +03:00
|
|
|
|
|
|
|
template <typename TCase>
|
|
|
|
void RunReaderTest() {
|
2021-04-09 09:44:51 +03:00
|
|
|
IJSValueWriter writer = winrt::make<JsiWriter>(*m_runtime);
|
2020-06-18 00:18:03 +03:00
|
|
|
TCase::Write(writer);
|
|
|
|
const facebook::jsi::Value *args = nullptr;
|
|
|
|
size_t count = 0;
|
|
|
|
writer.as<JsiWriter>()->AccessResultAsArgs(args, count);
|
2021-04-09 09:44:51 +03:00
|
|
|
IJSValueReader reader = winrt::make<JsiReader>(*m_runtime, args, count);
|
2020-06-18 00:18:03 +03:00
|
|
|
TCase::Read(reader);
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPORT_ARGUMENT_READER_TEST_CASES
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace winrt::Microsoft::ReactNative
|