From 66fcfcc4e7df350a98b212f99deaf607b1ee0324 Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Mon, 25 Dec 2023 12:49:45 +0100 Subject: [PATCH] Add tests --- tests/unittests/CMakeLists.txt | 1 + tests/unittests/test_iostream.cpp | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/unittests/test_iostream.cpp diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index 7ae940f5e8..15b6ce98f4 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable(unittests test_utils.cpp test_hash.cpp test_binarystream.cpp + test_iostream.cpp test_pe.cpp test_elf.cpp test_oat.cpp diff --git a/tests/unittests/test_iostream.cpp b/tests/unittests/test_iostream.cpp new file mode 100644 index 0000000000..5d78d92484 --- /dev/null +++ b/tests/unittests/test_iostream.cpp @@ -0,0 +1,32 @@ +/* Copyright 2017 - 2023 R. Thomas + * Copyright 2017 - 2023 Quarkslab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include "LIEF/span.hpp" +#include "LIEF/iostream.hpp" + +TEST_CASE("lief.test.iostream", "[lief][test][iostream]") { + SECTION("Span") { + std::vector buffer = {1, 2, 3, 4}; + LIEF::span span_buffer = buffer; + + LIEF::vector_iostream ios; + ios.write(span_buffer); + + REQUIRE(ios.raw() == buffer); + } +}