/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* 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 <iostream>
#include <string>
#include <gtest/gtest.h>
#include "disassembler.h"
using namespace panda::disasm;
#cmakedefine DISASM_BIN_DIR "@DISASM_BIN_DIR@/"
TEST(literals_test, literals_test_names)
{
Disassembler d {};
std::stringstream ss {};
d.Disassemble(std::string(DISASM_BIN_DIR) + "literals_same.bc");
d.Serialize(ss, false);
ASSERT_NE(ss.str().find(".language PandaAssembly"), std::string::npos);
ASSERT_NE(ss.str().find(".array array_0 i32 3 { 2 3 4 }"), std::string::npos);
ASSERT_NE(ss.str().find(".array array_1 i32 3 { 2 3 4 }"), std::string::npos);
ASSERT_NE(ss.str().find(".array array_2 i32 3 { 2 3 4 }"), std::string::npos);
ASSERT_NE(ss.str().find(".array array_3 i32 3 { 2 3 4 }"), std::string::npos);
}
TEST(literals_test, literals_test)
{
Disassembler d {};
std::stringstream ss {};
d.Disassemble(std::string(DISASM_BIN_DIR) + "literals.bc");
d.Serialize(ss, false);
ASSERT_NE(ss.str().find(".language PandaAssembly"), std::string::npos);
ASSERT_NE(ss.str().find(".record panda.String <external>"), std::string::npos);
ASSERT_NE(ss.str().find("panda.String 3 { \"a\" \"ab\" \"abc\" }"), std::string::npos);
ASSERT_NE(ss.str().find("u1 3 { 0 1 0 }"), std::string::npos);
ASSERT_NE(ss.str().find("i32 3 { 2 3 4 }"), std::string::npos);
ASSERT_NE(ss.str().find("f32 3 { 5.1 6.2 7.3 }"), std::string::npos);
}
#undef DISASM_BIN_DIR