-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenry_test.cpp
36 lines (26 loc) · 1.08 KB
/
enry_test.cpp
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
// enry_test.cpp
#include "enry.h"
#define DEBUG
#include <cassert>
#include <algorithm>
int main()
{
std::string lang = enry::GetLanguage("main.cpp", "auto main() -> int { return 0; }"); // C++
assert(lang.compare("C++") == 0);
std::string type = enry::GetMimeType("enry.pl", "Perl"); // text/x-perl
assert(type.compare("text/x-perl") == 0);
type = enry::GetLanguageType("HTML"); // markup
assert(type.compare("markup") == 0);
bool safe;
std::tie(lang, safe) = enry::GetLanguageByExtension("enry.h"); // C false
assert(!safe && lang.compare("C") == 0);
auto exts = enry::GetLanguageExtensions("Prolog");
assert(exts.size() > 0);
assert(std::count(exts.begin(), exts.end(), ".pl") == 1);
assert(std::count(exts.begin(), exts.end(), ".pro") == 1);
assert(std::count(exts.begin(), exts.end(), ".prolog") == 1);
auto langs = enry::GetLanguagesByModeline("modeline", "/* vim: set syntax=python ft=python filetype=python */", { "Python", "vim" });
assert(langs.size() > 0);
assert(langs.at(0).compare("Python") == 0);
return 0;
}