network-experiment/bmrshared-magic/tst/test_magic.cpp

27 lines
803 B
C++

// GNU Lesser General Public License v3.0
// Copyright (c) 2025 Bart Beumer <bart@4beumer.nl>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License v3.0 as published by
// the Free Software Foundation.
//
#include <bmrshared/magic_file_info.hpp>
#include <gtest/gtest.h>
namespace
{
constexpr std::string_view magic_file_location = "/usr/local/bin/magic.mgc";
}
TEST(test_magic, no_throw_on_query)
{
bmrshared::magic_file_info mfi(magic_file_location);
EXPECT_NO_THROW(mfi.get_mime(magic_file_location));
}
TEST(test_magic, throw_on_wrong_magic_file)
{
EXPECT_THROW(bmrshared::magic_file_info mfi(""), std::exception);
EXPECT_THROW(bmrshared::magic_file_info mfi("/etc/hostname"), std::exception);
}