File: makernote-test.cpp

package info (click to toggle)
exiv2 0.17.1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,668 kB
  • ctags: 5,254
  • sloc: cpp: 43,979; sh: 8,353; ansic: 1,641; makefile: 484; awk: 92; python: 36; sed: 16
file content (49 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <exiv2/makernote.hpp>

#include <iostream>
#include <string>
#include <utility>

void testMatch(const std::string& reg, const std::string& key);

int main()
{
    testMatch("Canon", "Canon");
    testMatch("Canon*", "Canon");
    testMatch("Canon*", "Canon Corp.");
    testMatch("PENTAX*", "PENTAX Corporation");
    testMatch("*foo*bar*", "foobar");
    testMatch("*foo*bar*", "barfoofoobarbar");
    testMatch("foo*bar", "foo");
    testMatch("foo*bar", "bar");
    testMatch("foo*bar", "foobar");
    testMatch("foo*bar", "fooYAHOObar");
    testMatch("foo*bar", "Thefoobar");
    testMatch("foo*bar", "foobarTrick");
    testMatch("foo*bar", "ThefoobarTrick");
    testMatch("foo*bar", "ThefooYAHOObarTrick");

    testMatch("*", "anything");
    testMatch("**", "anything times two");

    testMatch("*bar", "bar");
    testMatch("b*bar", "bar");
    testMatch("b*bar", "bbar");
    testMatch("*foobar", "bar");
    testMatch("*bar", "foobar");

    return 0;
}

void testMatch(const std::string& reg, const std::string& key)
{
    int rc = Exiv2::MakerNoteFactory::match(reg, key);

    if (rc) {
        std::cout << "Key '" << key << "' matches '" << reg << "' "
                  << "with a score of " << rc << ".\n";
    }
    else {
        std::cout << "Key '" << key << "' does not match '" << reg << "'.\n";
    }
}