RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
CameraMetaDataTest.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2009-2014 Klaus Post
5 Copyright (C) 2016 Roman Lebedev
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#include "rawspeedconfig.h"
23#include "metadata/Camera.h"
25#include <memory>
26#include <string>
27#include <gtest/gtest.h>
28
30using std::unique_ptr;
31
32namespace rawspeed_test {
33
34namespace {
35
36#ifdef HAVE_PUGIXML
37
38const std::string camfile(RAWSPEED_SOURCE_DIR "/data/cameras.xml");
39
40TEST(CameraMetaDataTest, CompileTimeCanInherit) {
41 struct MyCameraMetaData final : public CameraMetaData {};
42}
43
44TEST(CameraMetaDataTest, CamerasXml) {
45 ASSERT_NO_THROW({ CameraMetaData Data(camfile.c_str()); });
46
47 ASSERT_NO_THROW({
48 unique_ptr<CameraMetaData> Data(new CameraMetaData(camfile.c_str()));
49 });
50}
51
52TEST(CameraMetaDataTest, PrefixSearch) {
53 ASSERT_NO_THROW({
54 CameraMetaData Data(camfile.c_str());
55
56 const auto* d3 =
57 Data.getCamera("NIKON CORPORATION", "NIKON D3", "14bit-compressed");
58 ASSERT_NE(nullptr, d3);
59 ASSERT_EQ("D3", d3->canonical_model);
60
61 ASSERT_EQ(nullptr,
62 Data.getCamera("NIKON CORPORATION", "NIKON D3",
63 "14bit-compressed-with-some-bogus-prefix"));
64 ASSERT_EQ(nullptr, Data.getCamera("NIKON CORPORATION",
65 "NIKON D3-with-some-bogus-prefix",
66 "14bit-compressed"));
67 ASSERT_EQ(nullptr,
68 Data.getCamera("NIKON CORPORATION-with-some-bogus-prefix",
69 "NIKON D3", "14bit-compressed"));
70
71 d3 = Data.getCamera("NIKON CORPORATION", "NIKON D3");
72 ASSERT_NE(nullptr, d3);
73 ASSERT_EQ("D3", d3->canonical_model);
74
75 ASSERT_EQ(nullptr, Data.getCamera("NIKON CORPORATION",
76 "NIKON D3-with-some-bogus-prefix"));
77 ASSERT_EQ(
78 nullptr,
79 Data.getCamera("NIKON CORPORATION-with-some-bogus-prefix", "NIKON D3"));
80 ASSERT_EQ(nullptr,
81 Data.getCamera("NIKON CORPORATION-with-some-bogus-prefix",
82 "NIKON D3-with-some-bogus-prefix"));
83 });
84}
85
86#endif
87
88} // namespace
89
90} // namespace rawspeed_test
const Camera * getCamera(const std::string &make, const std::string &model, const std::string &mode) const