mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Tests: Removed common tests
This commit is contained in:
parent
2d420397f9
commit
bea3586638
9 changed files with 0 additions and 1230 deletions
8
test/.gitignore
vendored
8
test/.gitignore
vendored
|
@ -1,14 +1,6 @@
|
|||
all.log
|
||||
color.t
|
||||
fs.t
|
||||
grammar.t
|
||||
lexer.t
|
||||
lr0.t
|
||||
list.t
|
||||
pig.t
|
||||
rules.t
|
||||
rx.t
|
||||
table.t
|
||||
text.t
|
||||
unicode.t
|
||||
utf8.t
|
||||
|
|
192
test/color.t.cpp
192
test/color.t.cpp
|
@ -1,192 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <Color.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (40 + 256 + 256 + 6*6*6 + 6*6*6 + 1 + 24 + 24 + 3);
|
||||
|
||||
// Names matched to values.
|
||||
t.is ((int) Color (""), (int) Color (Color::nocolor), "'' == Color::nocolor");
|
||||
t.is ((int) Color ("black"), (int) Color (Color::black), "'black' == Color::black");
|
||||
t.is ((int) Color ("red"), (int) Color (Color::red), "'red' == Color::red");
|
||||
t.is ((int) Color ("green"), (int) Color (Color::green), "'green' == Color::green");
|
||||
t.is ((int) Color ("yellow"), (int) Color (Color::yellow), "'yellow' == Color::yellow");
|
||||
t.is ((int) Color ("blue"), (int) Color (Color::blue), "'blue' == Color::blue");
|
||||
t.is ((int) Color ("magenta"), (int) Color (Color::magenta), "'magenta' == Color::magenta");
|
||||
t.is ((int) Color ("cyan"), (int) Color (Color::cyan), "'cyan' == Color::cyan");
|
||||
t.is ((int) Color ("white"), (int) Color (Color::white), "'white' == Color::white");
|
||||
|
||||
// Auto upgrades.
|
||||
Color c ("red on color0");
|
||||
t.is ((std::string) c, "color1 on color0", "upgrade red on color0 -> color1 on color0");
|
||||
|
||||
c = Color ("color1 on black");
|
||||
t.is ((std::string) c, "color1 on color0", "upgrade color1 on black -> color1 on color0");
|
||||
|
||||
c = Color ("bold red on color0");
|
||||
t.is ((std::string) c, "color9 on color0", "upgrade bold red on color0 -> color9 on color0");
|
||||
|
||||
c = Color ("color1 on bright black");
|
||||
t.is ((std::string) c, "color1 on color8", "upgrade color1 on bright black -> color1 on color8");
|
||||
|
||||
// Simple blending.
|
||||
c = Color ("red");
|
||||
c.blend (Color ("on white"));
|
||||
t.is ((std::string) c, "red on white", "red + on white -> red on white");
|
||||
|
||||
c = Color ("bold underline red");
|
||||
c.blend (Color ("on bright white"));
|
||||
t.is ((std::string) c, "bold underline red on bright white", "bold underline red + on bright white -> bold underline red on bright white");
|
||||
|
||||
// Blending with conflicts.
|
||||
c = Color ("red on white");
|
||||
c.blend (Color ("on blue"));
|
||||
t.is ((std::string) c, "red on blue", "red on white + on blue -> red on blue");
|
||||
|
||||
c = Color ("red on white");
|
||||
c.blend (Color ("blue on magenta"));
|
||||
t.is ((std::string) c, "blue on magenta", "red on white + blue on magenta -> blue on magenta");
|
||||
|
||||
// Blending with upgrades.
|
||||
c = Color ("color1 on color0");
|
||||
c.blend (Color ("blue"));
|
||||
t.is ((std::string) c, "color4 on color0", "color1 on color0 + blue -> color4 on color0");
|
||||
|
||||
// Now the dumb show of every color and its code.
|
||||
t.is (Color::colorize ("foo", "red"), std::string ("\033[31mfoo\033[0m"), "red -> ^[[31m");
|
||||
t.is (Color::colorize ("foo", "bold red"), std::string ("\033[1;31mfoo\033[0m"), "bold red -> ^[[1;31m");
|
||||
t.is (Color::colorize ("foo", "underline red"), std::string ("\033[4;31mfoo\033[0m"), "underline red -> ^[[4;31m");
|
||||
t.is (Color::colorize ("foo", "underline bold red"), std::string ("\033[1;4;31mfoo\033[0m"), "underline bold red -> ^[[1;4;31m");
|
||||
|
||||
// 16-color foregrounds.
|
||||
t.is (Color::colorize ("foo", ""), std::string ("foo"), "'' -> ''");
|
||||
|
||||
t.is (Color::colorize ("foo", "black"), std::string ("\033[30mfoo\033[0m"), "black -> ^[[30m");
|
||||
t.is (Color::colorize ("foo", "red"), std::string ("\033[31mfoo\033[0m"), "red -> ^[[31m");
|
||||
t.is (Color::colorize ("foo", "green"), std::string ("\033[32mfoo\033[0m"), "green -> ^[[32m");
|
||||
t.is (Color::colorize ("foo", "yellow"), std::string ("\033[33mfoo\033[0m"), "yellow -> ^[[33m");
|
||||
t.is (Color::colorize ("foo", "blue"), std::string ("\033[34mfoo\033[0m"), "blue -> ^[[34m");
|
||||
t.is (Color::colorize ("foo", "magenta"), std::string ("\033[35mfoo\033[0m"), "magenta -> ^[[35m");
|
||||
t.is (Color::colorize ("foo", "cyan"), std::string ("\033[36mfoo\033[0m"), "cyan -> ^[[36m");
|
||||
t.is (Color::colorize ("foo", "white"), std::string ("\033[37mfoo\033[0m"), "white -> ^[[37m");
|
||||
|
||||
// 16-color backgrounds.
|
||||
t.is (Color::colorize ("foo", "on bright black"), std::string ("\033[100mfoo\033[0m"), "on bright black -> ^[[100m");
|
||||
|
||||
t.is (Color::colorize ("foo", "on black"), std::string ("\033[40mfoo\033[0m"), "on black -> ^[[40m");
|
||||
t.is (Color::colorize ("foo", "on red"), std::string ("\033[41mfoo\033[0m"), "on red -> ^[[41m");
|
||||
t.is (Color::colorize ("foo", "on green"), std::string ("\033[42mfoo\033[0m"), "on green -> ^[[42m");
|
||||
t.is (Color::colorize ("foo", "on yellow"), std::string ("\033[43mfoo\033[0m"), "on yellow -> ^[[43m");
|
||||
t.is (Color::colorize ("foo", "on blue"), std::string ("\033[44mfoo\033[0m"), "on blue -> ^[[44m");
|
||||
t.is (Color::colorize ("foo", "on magenta"), std::string ("\033[45mfoo\033[0m"), "on magenta -> ^[[45m");
|
||||
t.is (Color::colorize ("foo", "on cyan"), std::string ("\033[46mfoo\033[0m"), "on cyan -> ^[[46m");
|
||||
t.is (Color::colorize ("foo", "on white"), std::string ("\033[47mfoo\033[0m"), "on white -> ^[[47m");
|
||||
|
||||
// 256-color, basic colors.
|
||||
char color [24];
|
||||
char codes [64];
|
||||
char description [64];
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
sprintf (color, "color%d", i);
|
||||
sprintf (codes, "\033[38;5;%dmfoo\033[0m", i);
|
||||
sprintf (description, "color%d -> ^[[38;5;%dm", i, i);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
sprintf (color, "on color%d", i);
|
||||
sprintf (codes, "\033[48;5;%dmfoo\033[0m", i);
|
||||
sprintf (description, "on color%d -> ^[[48;5;%dm", i, i);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
// RGB Color Cube.
|
||||
for (int r = 0; r < 6; ++r)
|
||||
for (int g = 0; g < 6; ++g)
|
||||
for (int b = 0; b < 6; ++b)
|
||||
{
|
||||
int code = 16 + (r*36 + g*6 + b);
|
||||
sprintf (color, "rgb%d%d%d", r, g, b);
|
||||
sprintf (codes, "\033[38;5;%dmfoo\033[0m", code);
|
||||
sprintf (description, "rgb%d%d%d -> ^[[38;5;%dm", r, g, b, code);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
for (int r = 0; r < 6; ++r)
|
||||
for (int g = 0; g < 6; ++g)
|
||||
for (int b = 0; b < 6; ++b)
|
||||
{
|
||||
int code = 16 + (r*36 + g*6 + b);
|
||||
sprintf (color, "on rgb%d%d%d", r, g, b);
|
||||
sprintf (codes, "\033[48;5;%dmfoo\033[0m", code);
|
||||
sprintf (description, "on rgb%d%d%d -> ^[[48;5;%dm", r, g, b, code);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
// 256-color, grays.
|
||||
// grey == gray.
|
||||
t.is (Color::colorize ("foo", "grey0"), std::string ("\033[38;5;232mfoo\033[0m"), "grey0 -> ^[[38;5;232m");
|
||||
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
sprintf (color, "gray%d", i);
|
||||
sprintf (codes, "\033[38;5;%dmfoo\033[0m", i + 232);
|
||||
sprintf (description, "gray%d -> ^[[38;5;%dm", i + 232, i + 232);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
sprintf (color, "on gray%d", i);
|
||||
sprintf (codes, "\033[48;5;%dmfoo\033[0m", i + 232);
|
||||
sprintf (description, "on gray%d -> ^[[48;5;%dm", i + 232, i + 232);
|
||||
|
||||
t.is (Color::colorize ("foo", color), std::string (codes), description);
|
||||
}
|
||||
|
||||
// std::string Color::strip (const std::string&);
|
||||
t.is (Color::strip (""), "", "Color::strip '' -> ''");
|
||||
t.is (Color::strip ("foo"), "foo", "Color::strip 'foo' -> 'foo'");
|
||||
t.is (Color::strip ("f\033[1mo\033[0mo"), "foo", "Color::strip 'f<b>o</b>o' -> 'foo'");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
290
test/fs.t.cpp
290
test/fs.t.cpp
|
@ -1,290 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <FS.h>
|
||||
#include <test.h>
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (112);
|
||||
|
||||
// Path ();
|
||||
Path p0;
|
||||
t.is (p0._data, "", "Path::Path");
|
||||
|
||||
// Path (const Path&);
|
||||
Path p1 = Path ("foo");
|
||||
t.is (p1._data, Directory::cwd () + "/foo", "Path::operator=");
|
||||
|
||||
// Path (const std::string&);
|
||||
Path p2 ("~");
|
||||
t.ok (p2._data != "~", "~ expanded to " + p2._data);
|
||||
|
||||
Path p3 ("/tmp");
|
||||
t.ok (p3._data == "/tmp", "/tmp -> /tmp");
|
||||
|
||||
// operator==
|
||||
t.notok (p2 == p3, "p2 != p3");
|
||||
|
||||
// Path& operator= (const Path&);
|
||||
Path p3_copy (p3);
|
||||
t.is (p3._data, p3_copy._data, "Path::Path (Path&)");
|
||||
|
||||
// operator (std::string) const;
|
||||
t.is ((std::string) p3, "/tmp", "Path::operator (std::string) const");
|
||||
|
||||
// std::string name () const;
|
||||
Path p4 ("/a/b/c/file.ext");
|
||||
t.is (p4.name (), "file.ext", "/a/b/c/file.ext name is file.ext");
|
||||
|
||||
// std::string parent () const;
|
||||
t.is (p4.parent (), "/a/b/c", "/a/b/c/file.ext parent is /a/b/c");
|
||||
|
||||
// std::string extension () const;
|
||||
t.is (p4.extension (), "ext", "/a/b/c/file.ext extension is ext");
|
||||
|
||||
// bool exists () const;
|
||||
t.ok (p2.exists (), "~ exists");
|
||||
t.ok (p3.exists (), "/tmp exists");
|
||||
|
||||
// bool is_directory () const;
|
||||
t.ok (p2.is_directory (), "~ is_directory");
|
||||
t.ok (p3.is_directory (), "/tmp is_directory");
|
||||
|
||||
// bool is_link () const;
|
||||
t.notok (p2.is_link (), "~ !is_link");
|
||||
|
||||
// bool readable () const;
|
||||
t.ok (p2.readable (), "~ readable");
|
||||
t.ok (p3.readable (), "/tmp readable");
|
||||
|
||||
// bool writable () const;
|
||||
t.ok (p2.writable (), "~ writable");
|
||||
t.ok (p3.writable (), "/tmp writable");
|
||||
|
||||
// bool executable () const;
|
||||
t.ok (p2.executable (), "~ executable");
|
||||
t.ok (p3.executable (), "/tmp executable");
|
||||
|
||||
// static std::string expand (const std::string&);
|
||||
t.ok (Path::expand ("~") != "~", "Path::expand ~ != ~");
|
||||
t.ok (Path::expand ("~/") != "~/", "Path::expand ~/ != ~/");
|
||||
|
||||
// static std::vector <std::string> glob (const std::string&);
|
||||
std::vector <std::string> out = Path::glob ("/tmp");
|
||||
t.ok (out.size () == 1, "/tmp -> 1 result");
|
||||
t.is (out[0], "/tmp", "/tmp -> /tmp");
|
||||
|
||||
out = Path::glob ("/t?p");
|
||||
t.ok (out.size () == 1, "/t?p -> 1 result");
|
||||
t.is (out[0], "/tmp", "/t?p -> /tmp");
|
||||
|
||||
out = Path::glob ("/[s-u]mp");
|
||||
t.ok (out.size () == 1, "/[s-u]mp -> 1 result");
|
||||
t.is (out[0], "/tmp", "/[s-u]mp -> /tmp");
|
||||
|
||||
// bool is_absolute () const;
|
||||
t.notok (p0.is_absolute (), "'' !is_absolute");
|
||||
t.ok (p1.is_absolute (), "foo is_absolute");
|
||||
t.ok (p2.is_absolute (), "~ is_absolute (after expansion)");
|
||||
t.ok (p3.is_absolute (), "/tmp is_absolute");
|
||||
t.ok (p4.is_absolute (), "/a/b/c/file.ext is_absolute");
|
||||
|
||||
Path p5 ("~/file.ext");
|
||||
t.notok (p5.name () == "~/file.ext", "~/file.ext --> ! ~/file.ext");
|
||||
|
||||
Directory tmp ("tmp");
|
||||
tmp.create ();
|
||||
t.ok (tmp.exists (), "tmp dir created.");
|
||||
|
||||
File::write ("tmp/file.t.txt", "This is a test\n");
|
||||
File f6 ("tmp/file.t.txt");
|
||||
t.ok (f6.size () == 15, "File::size tmp/file.t.txt good");
|
||||
t.ok (f6.mode () & S_IRUSR, "File::mode tmp/file.t.txt good");
|
||||
t.ok (File::remove ("tmp/file.t.txt"), "File::remove tmp/file.t.txt good");
|
||||
|
||||
// operator (std::string) const;
|
||||
t.is ((std::string) f6, Directory::cwd () + "/tmp/file.t.txt", "File::operator (std::string) const");
|
||||
|
||||
t.ok (File::create ("tmp/file.t.create"), "File::create tmp/file.t.create good");
|
||||
t.ok (File::remove ("tmp/file.t.create"), "File::remove tmp/file.t.create good");
|
||||
|
||||
// basename (std::string) const;
|
||||
t.is (f6.name (), "file.t.txt", "File::basename tmp/file.t.txt --> file.t.txt");
|
||||
|
||||
// dirname (std::string) const;
|
||||
t.is (f6.parent (), Directory::cwd () + "/tmp", "File::dirname tmp/file.t.txt --> tmp");
|
||||
|
||||
// bool rename (const std::string&);
|
||||
File f7 ("tmp/file.t.2.txt");
|
||||
f7.append ("something\n");
|
||||
f7.close ();
|
||||
|
||||
t.ok (f7.rename ("tmp/file.t.3.txt"), "File::rename did not fail");
|
||||
t.is (f7._data, Directory::cwd () + "/tmp/file.t.3.txt", "File::rename stored new name");
|
||||
t.ok (f7.exists (), "File::rename new file exists");
|
||||
t.ok (f7.remove (), "File::remove tmp/file.t.3.txt good");
|
||||
t.notok (f7.exists (), "File::remove new file no longer exists");
|
||||
|
||||
// Test permissions.
|
||||
File f8 ("tmp/file.t.perm.txt");
|
||||
f8.create (0744);
|
||||
t.ok (f8.exists (), "File::create perm file exists");
|
||||
mode_t m = f8.mode ();
|
||||
t.ok (m & S_IFREG, "File::mode tmp/file.t.perm.txt S_IFREG good");
|
||||
t.ok (m & S_IRUSR, "File::mode tmp/file.t.perm.txt r-------- good");
|
||||
t.ok (m & S_IWUSR, "File::mode tmp/file.t.perm.txt -w------- good");
|
||||
t.ok (m & S_IXUSR, "File::mode tmp/file.t.perm.txt --x------ good");
|
||||
t.ok (m & S_IRGRP, "File::mode tmp/file.t.perm.txt ---r----- good");
|
||||
t.notok (m & S_IWGRP, "File::mode tmp/file.t.perm.txt ----w---- good");
|
||||
t.notok (m & S_IXGRP, "File::mode tmp/file.t.perm.txt -----x--- good");
|
||||
t.ok (m & S_IROTH, "File::mode tmp/file.t.perm.txt ------r-- good");
|
||||
t.notok (m & S_IWOTH, "File::mode tmp/file.t.perm.txt -------w- good");
|
||||
t.notok (m & S_IXOTH, "File::mode tmp/file.t.perm.txt --------x good");
|
||||
f8.remove ();
|
||||
t.notok (f8.exists (), "File::remove perm file no longer exists");
|
||||
|
||||
tmp.remove ();
|
||||
t.notok (tmp.exists (), "tmp dir removed.");
|
||||
tmp.create ();
|
||||
t.ok (tmp.exists (), "tmp dir created.");
|
||||
|
||||
// Directory (const File&);
|
||||
// Directory (const Path&);
|
||||
Directory d0 (Path ("tmp"));
|
||||
Directory d1 (File ("tmp"));
|
||||
Directory d2 (File (Path ("tmp")));
|
||||
t.is (d0._data, d1._data, "Directory(std::string) == Directory (File&)");
|
||||
t.is (d0._data, d2._data, "Directory(std::string) == Directory (File (Path &))");
|
||||
t.is (d1._data, d2._data, "Directory(File&)) == Directory (File (Path &))");
|
||||
|
||||
// Directory (const Directory&);
|
||||
Directory d3 (d2);
|
||||
t.is (d3._data, Directory::cwd () + "/tmp", "Directory (Directory&)");
|
||||
|
||||
// Directory (const std::string&);
|
||||
Directory d4 ("tmp/test_directory");
|
||||
|
||||
// Directory& operator= (const Directory&);
|
||||
Directory d5 = d4;
|
||||
t.is (d5._data, Directory::cwd () + "/tmp/test_directory", "Directory::operator=");
|
||||
|
||||
// operator (std::string) const;
|
||||
t.is ((std::string) d3, Directory::cwd () + "/tmp", "Directory::operator (std::string) const");
|
||||
|
||||
// virtual bool create ();
|
||||
t.ok (d5.create (), "Directory::create tmp/test_directory");
|
||||
t.ok (d5.exists (), "Directory::exists tmp/test_directory");
|
||||
|
||||
Directory d6 (d5._data + "/dir");
|
||||
t.ok (d6.create (), "Directory::create tmp/test_directory/dir");
|
||||
|
||||
File::create (d5._data + "/f0");
|
||||
File::create (d6._data + "/f1");
|
||||
|
||||
// std::vector <std::string> list ();
|
||||
std::vector <std::string> files = d5.list ();
|
||||
std::sort (files.begin (), files.end ());
|
||||
t.is ((int)files.size (), 2, "Directory::list 1 file");
|
||||
t.is (files[0], Directory::cwd () + "/tmp/test_directory/dir", "file[0] is tmp/test_directory/dir");
|
||||
t.is (files[1], Directory::cwd () + "/tmp/test_directory/f0", "file[1] is tmp/test_directory/f0");
|
||||
|
||||
// std::vector <std::string> listRecursive ();
|
||||
files = d5.listRecursive ();
|
||||
std::sort (files.begin (), files.end ());
|
||||
t.is ((int)files.size (), 2, "Directory::list 1 file");
|
||||
t.is (files[0], Directory::cwd () + "/tmp/test_directory/dir/f1", "file is tmp/test_directory/dir/f1");
|
||||
t.is (files[1], Directory::cwd () + "/tmp/test_directory/f0", "file is tmp/test_directory/f0");
|
||||
|
||||
// virtual bool remove ();
|
||||
t.ok (File::remove (d5._data + "/f0"), "File::remove tmp/test_directory/f0");
|
||||
t.ok (File::remove (d6._data + "/f1"), "File::remove tmp/test_directory/dir/f1");
|
||||
|
||||
t.ok (d6.remove (), "Directory::remove tmp/test_directory/dir");
|
||||
t.notok (d6.exists (), "Directory::exists tmp/test_directory/dir - no");
|
||||
|
||||
t.ok (d5.remove (), "Directory::remove tmp/test_directory");
|
||||
t.notok (d5.exists (), "Directory::exists tmp/test_directory - no");
|
||||
|
||||
// bool remove (const std::string&);
|
||||
Directory d7 ("tmp/to_be_removed");
|
||||
t.ok (d7.create (), "Directory::create tmp/to_be_removed");
|
||||
File::create (d7._data + "/f0");
|
||||
Directory d8 (d7._data + "/another");
|
||||
t.ok (d8.create (), "Directory::create tmp/to_be_removed/another");
|
||||
File::create (d8._data + "/f1");
|
||||
t.ok (d7.remove (), "Directory::remove tmp/to_be_removed");
|
||||
t.notok (d7.exists (), "Directory tmp/to_be_removed gone");
|
||||
|
||||
// static std::string cwd ();
|
||||
std::string cwd = Directory::cwd ();
|
||||
t.ok (cwd.length () > 0, "Directory::cwd returned a value");
|
||||
|
||||
// bool parent (std::string&) const;
|
||||
Directory d9 ("/one/two/three/four.txt");
|
||||
t.ok (d9.up (), "parent /one/two/three/four.txt --> true");
|
||||
t.is (d9._data, "/one/two/three", "parent /one/two/three/four.txt --> /one/two/three");
|
||||
t.ok (d9.up (), "parent /one/two/three --> true");
|
||||
t.is (d9._data, "/one/two", "parent /one/two/three --> /one/two");
|
||||
t.ok (d9.up (), "parent /one/two --> true");
|
||||
t.is (d9._data, "/one", "parent /one/two --> /one");
|
||||
t.ok (d9.up (), "parent /one --> true");
|
||||
t.is (d9._data, "/", "parent /one --> /");
|
||||
t.notok (d9.up (), "parent / --> false");
|
||||
|
||||
// Test permissions.
|
||||
umask (0022);
|
||||
Directory d10 ("tmp/dir.perm");
|
||||
d10.create (0750);
|
||||
t.ok (d10.exists (), "Directory::create perm file exists");
|
||||
m = d10.mode ();
|
||||
t.ok (m & S_IFDIR, "Directory::mode tmp/dir.perm S_IFDIR good");
|
||||
t.ok (m & S_IRUSR, "Directory::mode tmp/dir.perm r-------- good");
|
||||
t.ok (m & S_IWUSR, "Directory::mode tmp/dir.perm -w------- good");
|
||||
t.ok (m & S_IXUSR, "Directory::mode tmp/dir.perm --x------ good");
|
||||
t.ok (m & S_IRGRP, "Directory::mode tmp/dir.perm ---r----- good");
|
||||
t.notok (m & S_IWGRP, "Directory::mode tmp/dir.perm ----w---- good");
|
||||
t.ok (m & S_IXGRP, "Directory::mode tmp/dir.perm -----x--- good");
|
||||
t.notok (m & S_IROTH, "Directory::mode tmp/dir.perm ------r-- good");
|
||||
t.notok (m & S_IWOTH, "Directory::mode tmp/dir.perm -------w- good");
|
||||
t.notok (m & S_IXOTH, "Directory::mode tmp/dir.perm --------x good");
|
||||
d10.remove ();
|
||||
t.notok (d10.exists (), "Directory::remove temp/dir.perm file no longer exists");
|
||||
|
||||
// Directory::cd
|
||||
Directory d11 ("/tmp");
|
||||
t.ok (d11.cd (), "Directory::cd /tmp good");
|
||||
|
||||
tmp.remove ();
|
||||
t.notok (tmp.exists (), "tmp dir removed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,75 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <text.h>
|
||||
#include <test.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (8);
|
||||
|
||||
// 1,2,3 <=> 2,3,4
|
||||
std::vector <std::string> string_one {"1", "2", "3"};
|
||||
std::vector <std::string> string_two {"2", "3", "4"};
|
||||
std::vector <std::string> string_three {"2", "3", "4"};
|
||||
std::vector <std::string> string_four;
|
||||
|
||||
// What are the differences?
|
||||
std::vector<std::string> string_leftOnly;
|
||||
std::vector<std::string> string_rightOnly;
|
||||
listDiff (string_one, string_two, string_leftOnly, string_rightOnly);
|
||||
t.is ((int) string_leftOnly.size (), 1, "std::string (1,2,3) <=> (2,3,4) = 1<-");
|
||||
t.is (string_leftOnly[0], "1", "std::string (1,2,3) <=> (2,3,4) = 1<-");
|
||||
|
||||
t.is ((int) string_rightOnly.size (), 1, "std::string (1,2,3) <=> (2,3,4) = ->4");
|
||||
t.is (string_rightOnly[0], "4", "std::string (1,2,3) <=> (2,3,4) = ->4");
|
||||
|
||||
// Now do it all again, with integers.
|
||||
|
||||
// 1,2,3 <=> 2,3,4
|
||||
std::vector <int> int_one {1, 2, 3};
|
||||
std::vector <int> int_two {2, 3, 4};
|
||||
std::vector <int> int_three {2, 3, 4};
|
||||
std::vector <int> int_four;
|
||||
|
||||
// What are the differences?
|
||||
std::vector<int> int_leftOnly;
|
||||
std::vector<int> int_rightOnly;
|
||||
listDiff (int_one, int_two, int_leftOnly, int_rightOnly);
|
||||
t.is ((int) int_leftOnly.size (), 1, "int (1,2,3) <=> (2,3,4) = 1<-");
|
||||
t.is (int_leftOnly[0], "1", "int (1,2,3) <=> (2,3,4) = 1<-");
|
||||
|
||||
t.is ((int) int_rightOnly.size (), 1, "int (1,2,3) <=> (2,3,4) = ->4");
|
||||
t.is (int_rightOnly[0], "4", "int (1,2,3) <=> (2,3,4) = ->4");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
133
test/rx.t.cpp
133
test/rx.t.cpp
|
@ -1,133 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <RX.h>
|
||||
#include <test.h>
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest ut (26);
|
||||
|
||||
std::string text = "This is a test.";
|
||||
RX r1 ("i. ", true);
|
||||
ut.ok (r1.match (text), text + " =~ /i. /");
|
||||
|
||||
std::vector <std::string> matches;
|
||||
ut.ok (r1.match (matches, text), text + " =~ /i. /");
|
||||
ut.ok (matches.size () == 2, "2 match");
|
||||
ut.is (matches[0], "is ", "$1 == is\\s");
|
||||
ut.is (matches[1], "is ", "$1 == is\\s");
|
||||
|
||||
text = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
RX r3 ("t..", true);
|
||||
ut.ok (r3.match (text), "t..");
|
||||
|
||||
RX r4 ("T..", false);
|
||||
ut.ok (r4.match (text), "T..");
|
||||
|
||||
RX r5 ("T..", true);
|
||||
ut.ok (!r5.match (text), "! T..");
|
||||
|
||||
text = "this is a test of the regex engine.";
|
||||
// |...:....|....:....|....:....|....:
|
||||
|
||||
RX r6 ("^this");
|
||||
ut.ok (r6.match (text), "^this matches");
|
||||
|
||||
RX r7 ("engine\\.$");
|
||||
ut.ok (r7.match (text), "engine\\.$ matches");
|
||||
|
||||
std::vector <std::string> results;
|
||||
std::vector <int> start;
|
||||
std::vector <int> end;
|
||||
RX r8 ("e..", true);
|
||||
ut.ok (r8.match (results, text), "e.. there are matches");
|
||||
ut.ok (r8.match (start, end, text), "e.. there are matches");
|
||||
ut.is (results.size (), (size_t) 4, "e.. == 4 matches");
|
||||
ut.is (results[0], "est", "e..[0] == 'est'");
|
||||
ut.is (start[0], 11, "e..[0] == 11->");
|
||||
ut.is (end[0], 14, "e..[0] == ->14");
|
||||
|
||||
results.clear ();
|
||||
RX r9 ("e", true);
|
||||
ut.ok (r9.match (results, text), "e there are matches");
|
||||
ut.is (results.size (), (size_t) 6, "e == 6 matches");
|
||||
|
||||
start.clear ();
|
||||
end.clear ();
|
||||
ut.ok (r9.match (start, end, text), "e there are matches");
|
||||
ut.is (start.size (), (size_t) 6, "e == 6 matches");
|
||||
|
||||
#if defined(DARWIN) || defined(CYGWIN) || defined(FREEBSD) || defined(OPENBSD)
|
||||
text = "this is the end.";
|
||||
ut.pass (text + " =~ /\\bthe/");
|
||||
ut.pass (text + " =~ /the\\b/");
|
||||
ut.pass (text + " =~ /\\bthe\\b/");
|
||||
#elif defined(SOLARIS)
|
||||
RX r10 ("\\<the");
|
||||
text = "this is the end.";
|
||||
ut.ok (r10.match (text), text + " =~ /\\<the/");
|
||||
|
||||
RX r11 ("the\\>");
|
||||
ut.ok (r11.match (text), text + " =~ /the\\>/");
|
||||
|
||||
RX r12 ("\\<the\\>");
|
||||
ut.ok (r12.match (text), text + " =~ /\\<the\\>/");
|
||||
#else
|
||||
RX r10 ("\\bthe");
|
||||
text = "this is the end.";
|
||||
ut.ok (r10.match (text), text + " =~ /\\bthe/");
|
||||
|
||||
RX r11 ("the\\b");
|
||||
ut.ok (r11.match (text), text + " =~ /the\\b/");
|
||||
|
||||
RX r12 ("\\bthe\\b");
|
||||
ut.ok (r12.match (text), text + " =~ /\\bthe\\b/");
|
||||
#endif
|
||||
|
||||
#if defined(DARWIN)
|
||||
text = "D0";
|
||||
RX r13 ("D\\d");
|
||||
ut.ok (r13.match (text), text + " =~ /D\\d/");
|
||||
#else
|
||||
ut.skip (" =~ /D\\d/");
|
||||
#endif
|
||||
|
||||
text = "D0";
|
||||
RX r14 ("D[[:digit:]]");
|
||||
ut.ok (r14.match (text), text + " =~ /D[[:digit:]]/");
|
||||
|
||||
text = "D0";
|
||||
RX r15 ("D[0-9]");
|
||||
ut.ok (r15.match (text), text + " =~ /D[0-9]/");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
130
test/table.t.cpp
130
test/table.t.cpp
|
@ -1,130 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Table.h>
|
||||
#include <iostream>
|
||||
//#include <stdlib.h>
|
||||
//#include <unistd.h>
|
||||
//#include <stdio.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (1);
|
||||
|
||||
try
|
||||
{
|
||||
// Create colors.
|
||||
Color header_color (Color (Color::yellow, Color::nocolor, false, false, false));
|
||||
Color odd_color ("on gray1");
|
||||
Color even_color ("on gray0");
|
||||
|
||||
// Now render a string-only grid.
|
||||
Color single_cell ("bold white on red");
|
||||
|
||||
Table t1;
|
||||
t1.width (80);
|
||||
t1.leftMargin (4);
|
||||
t1.extraPadding (0);
|
||||
t1.intraPadding (1);
|
||||
t1.colorHeader (header_color);
|
||||
t1.colorOdd (odd_color);
|
||||
t1.colorEven (even_color);
|
||||
t1.intraColorOdd (odd_color);
|
||||
t1.intraColorEven (even_color);
|
||||
|
||||
// t1.add (Column::factory ("string", "One"));
|
||||
// t1.add (Column::factory ("string", "Two"));
|
||||
// t1.add (Column::factory ("string", "Three"));
|
||||
t1.add ("Header1", true);
|
||||
t1.add ("Header2", true);
|
||||
t1.add ("Header3", false);
|
||||
|
||||
int row = t1.addRow ();
|
||||
t1.set (row, 0, "top left");
|
||||
t1.set (row, 1, "top center");
|
||||
t1.set (row, 2, "top right");
|
||||
|
||||
row = t1.addRow ();
|
||||
t1.set (row, 0, "bottom left", single_cell);
|
||||
t1.set (row, 1, "bottom center, containing sufficient text that "
|
||||
"wrapping will occur because it exceeds all "
|
||||
"reasonable values for default width. Even in a "
|
||||
"very wide terminal window. Just look at the "
|
||||
"lengths we must go to, to get passing unit tests "
|
||||
"and not flaky tests.");
|
||||
t1.set (row, 2, "bottom right");
|
||||
|
||||
std::cout << t1.render ();
|
||||
t.ok (t1.lines () > 4, "Table::lines > 4");
|
||||
|
||||
// Chessboard example
|
||||
Table t2;
|
||||
t2.width (32);
|
||||
t2.leftMargin (4);
|
||||
t2.extraPadding (0);
|
||||
t2.intraPadding (0);
|
||||
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
t2.add ("", true);
|
||||
|
||||
Color blue ("on bright blue");
|
||||
Color white ("on bright white");
|
||||
|
||||
for (row = 0; row < 8; ++row)
|
||||
{
|
||||
t2.addRow ();
|
||||
|
||||
for (int col = 0; col < 8; ++col)
|
||||
{
|
||||
if ((row + col) % 2)
|
||||
t2.set (row, col, " ", blue);
|
||||
else
|
||||
t2.set (row, col, " ", white);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << t2.render ();
|
||||
}
|
||||
|
||||
catch (const std::string& e)
|
||||
{
|
||||
t.fail ("Exception thrown.");
|
||||
t.diag (e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
191
test/text.t.cpp
191
test/text.t.cpp
|
@ -1,191 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <text.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (76);
|
||||
|
||||
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width, bool hyphenate)
|
||||
std::string text = "This is a test of the line wrapping code.";
|
||||
std::vector <std::string> lines;
|
||||
wrapText (lines, text, 10, true);
|
||||
t.is (lines.size (), (size_t) 5, "wrapText 'This is a test of the line wrapping code.' -> total 5 lines");
|
||||
t.is (lines[0], "This is a", "wrapText line 0 -> 'This is a'");
|
||||
t.is (lines[1], "test of", "wrapText line 1 -> 'test of'");
|
||||
t.is (lines[2], "the line", "wrapText line 2 -> 'the line'");
|
||||
t.is (lines[3], "wrapping", "wrapText line 3 -> 'wrapping'");
|
||||
t.is (lines[4], "code.", "wrapText line 4 -> 'code.'");
|
||||
|
||||
text = "This ☺ is a test of utf8 line extraction.";
|
||||
lines.clear ();
|
||||
wrapText (lines, text, 7, true);
|
||||
t.is (lines.size (), (size_t) 7, "wrapText 'This ☺ is a test of utf8 line extraction.' -> total 7 lines");
|
||||
t.is (lines[0], "This ☺", "wrapText line 0 -> 'This ☺'");
|
||||
t.is (lines[1], "is a", "wrapText line 1 -> 'is a'");
|
||||
t.is (lines[2], "test of", "wrapText line 2 -> 'test of'");
|
||||
t.is (lines[3], "utf8", "wrapText line 3 -> 'utf8'");
|
||||
t.is (lines[4], "line", "wrapText line 4 -> 'line'");
|
||||
t.is (lines[5], "extrac-", "wrapText line 5 -> 'extrac-'");
|
||||
t.is (lines[6], "tion.", "wrapText line 6 -> 'tion.'");
|
||||
|
||||
text = "one two three\n four";
|
||||
lines.clear ();
|
||||
wrapText (lines, text, 13, true);
|
||||
t.is (lines.size (), (size_t) 2, "wrapText 'one two three\\n four' -> 2 lines");
|
||||
t.is (lines[0], "one two three", "wrapText line 0 -> 'one two three'");
|
||||
t.is (lines[1], " four", "wrapText line 1 -> ' four'");
|
||||
|
||||
// void extractLine (std::string& text, std::string& line, int length, bool hyphenate, unsigned int& offset)
|
||||
text = "This ☺ is a test of utf8 line extraction.";
|
||||
unsigned int offset = 0;
|
||||
std::string line;
|
||||
extractLine (line, text, 7, true, offset);
|
||||
t.is (line, "This ☺", "extractLine 7 'This ☺ is a test of utf8 line extraction.' -> 'This ☺'");
|
||||
|
||||
// void extractLine (std::string& text, std::string& line, int length, bool hyphenate, unsigned int& offset)
|
||||
text = "line 1\nlengthy second line that exceeds width";
|
||||
offset = 0;
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "line 1", "extractLine 10 'line 1\\nlengthy second line that exceeds width' -> 'line 1'");
|
||||
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "lengthy", "extractLine 10 'lengthy second line that exceeds width' -> 'lengthy'");
|
||||
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "second", "extractLine 10 'second line that exceeds width' -> 'second'");
|
||||
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "line that", "extractLine 10 'line that exceeds width' -> 'line that'");
|
||||
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "exceeds", "extractLine 10 'exceeds width' -> 'exceeds'");
|
||||
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "width", "extractLine 10 'width' -> 'width'");
|
||||
|
||||
t.notok (extractLine (line, text, 10, true, offset), "extractLine 10 '' -> ''");
|
||||
|
||||
text = "AAAAAAAAAABBBBBBBBBB";
|
||||
offset = 0;
|
||||
extractLine (line, text, 10, true, offset);
|
||||
t.is (line, "AAAAAAAAA-", "extractLine hyphenated unbreakable line");
|
||||
t.diag (line);
|
||||
|
||||
// void split (std::vector<std::string>& results, const std::string& input, const char delimiter)
|
||||
std::string unsplit = "";
|
||||
std::vector <std::string> items = split (unsplit, '-');
|
||||
t.is (items.size (), (size_t) 0, "split '' '-' -> 0 items");
|
||||
|
||||
unsplit = "a";
|
||||
items = split (unsplit, '-');
|
||||
t.is (items.size (), (size_t) 1, "split 'a' '-' -> 1 item");
|
||||
t.is (items[0], "a", "split 'a' '-' -> 'a'");
|
||||
|
||||
items = split (unsplit, '-');
|
||||
t.is (items.size (), (size_t) 1, "split 'a' '-' -> 1 item");
|
||||
t.is (items[0], "a", "split 'a' '-' -> 'a'");
|
||||
|
||||
unsplit = "-";
|
||||
items = split (unsplit, '-');
|
||||
t.is (items.size (), (size_t) 2, "split '-' '-' -> '' ''");
|
||||
t.is (items[0], "", "split '-' '-' -> [0] ''");
|
||||
t.is (items[1], "", "split '-' '-' -> [1] ''");
|
||||
|
||||
unsplit = "-a-bc-def";
|
||||
items = split (unsplit, '-');
|
||||
t.is (items.size (), (size_t) 4, "split '-a-bc-def' '-' -> '' 'a' 'bc' 'def'");
|
||||
t.is (items[0], "", "split '-a-bc-def' '-' -> [0] ''");
|
||||
t.is (items[1], "a", "split '-a-bc-def' '-' -> [1] 'a'");
|
||||
t.is (items[2], "bc", "split '-a-bc-def' '-' -> [2] 'bc'");
|
||||
t.is (items[3], "def", "split '-a-bc-def' '-' -> [3] 'def'");
|
||||
|
||||
// int longestWord (const std::string&)
|
||||
t.is (longestWord (" "), 0, "longestWord ( ) --> 0");
|
||||
t.is (longestWord ("this is a test"), 4, "longestWord (this is a test) --> 4");
|
||||
t.is (longestWord ("this is a better test"), 6, "longestWord (this is a better test) --> 6");
|
||||
t.is (longestWord ("house Çirçös clown"), 6, "longestWord (Çirçös) --> 6");
|
||||
|
||||
// int longestLine (const std::string&)
|
||||
t.is (longestLine ("one two three four"), 18, "longestLine (one two three four) --> 18");
|
||||
t.is (longestLine ("one\ntwo three four"), 14, "longestLine (one\\ntwo three four) --> 14");
|
||||
t.is (longestLine ("one\ntwo\nthree\nfour"), 5, "longestLine (one\\ntwo\\nthree\\nfour) --> 5");
|
||||
|
||||
// std::string format (char);
|
||||
t.is (format ('A'), "A", "format ('A') -> A");
|
||||
|
||||
// std::string format (int);
|
||||
t.is (format (0), "0", "format (0) -> 0");
|
||||
t.is (format (-1), "-1", "format (-1) -> -1");
|
||||
|
||||
// std::string formatHex (int);
|
||||
t.is (formatHex (0), "0", "formatHex (0) -> 0");
|
||||
t.is (formatHex (10), "a", "formatHex (10) -> a");
|
||||
t.is (formatHex (123), "7b", "formatHex (123) -> 7b");
|
||||
|
||||
// std::string format (float, int, int);
|
||||
t.is (format (0.12345678, 8, 4), " 0.1235", "format (0.12345678, 8, 4) -> __0.1235");
|
||||
|
||||
t.is (format (1.23456789, 8, 1), " 1", "format (1.23456789, 8, 1) -> _______1");
|
||||
t.is (format (1.23456789, 8, 2), " 1.2", "format (1.23456789, 8, 2) -> _____1.2");
|
||||
t.is (format (1.23456789, 8, 3), " 1.23", "format (1.23456789, 8, 3) -> ____1.23");
|
||||
t.is (format (1.23456789, 8, 4), " 1.235", "format (1.23456789, 8, 4) -> ___1.235");
|
||||
t.is (format (1.23456789, 8, 5), " 1.2346", "format (1.23456789, 8, 5) -> __1.2346");
|
||||
t.is (format (1.23456789, 8, 6), " 1.23457", "format (1.23456789, 8, 6) -> 1.23457");
|
||||
t.is (format (1.23456789, 8, 7), "1.234568", "format (1.23456789, 8, 7) -> 1.234568");
|
||||
t.is (format (1.23456789, 8, 8), "1.2345679", "format (1.23456789, 8, 8) -> 1.2345679");
|
||||
t.is (format (2444238.56789, 12, 11), "2444238.5679", "format (2444238.56789, 12, 11) -> 2444238.5679");
|
||||
|
||||
// std::string leftJustify (const std::string&, const int);
|
||||
t.is (leftJustify (123, 3), "123", "leftJustify 123,3 -> '123'");
|
||||
t.is (leftJustify (123, 4), "123 ", "leftJustify 123,4 -> '123 '");
|
||||
t.is (leftJustify (123, 5), "123 ", "leftJustify 123,5 -> '123 '");
|
||||
|
||||
// std::string leftJustify (const std::string&, const int);
|
||||
t.is (leftJustify ("foo", 3), "foo", "leftJustify foo,3 -> 'foo'");
|
||||
t.is (leftJustify ("foo", 4), "foo ", "leftJustify foo,4 -> 'foo '");
|
||||
t.is (leftJustify ("foo", 5), "foo ", "leftJustify foo,5 -> 'foo '");
|
||||
t.is (leftJustify ("föo", 5), "föo ", "leftJustify föo,5 -> 'föo '");
|
||||
|
||||
// std::string rightJustify (const std::string&, const int);
|
||||
t.is (rightJustify (123, 3), "123", "rightJustify 123,3 -> '123'");
|
||||
t.is (rightJustify (123, 4), " 123", "rightJustify 123,4 -> ' 123'");
|
||||
t.is (rightJustify (123, 5), " 123", "rightJustify 123,5 -> ' 123'");
|
||||
|
||||
// std::string rightJustify (const std::string&, const int);
|
||||
t.is (rightJustify ("foo", 3), "foo", "rightJustify foo,3 -> 'foo'");
|
||||
t.is (rightJustify ("foo", 4), " foo", "rightJustify foo,4 -> ' foo'");
|
||||
t.is (rightJustify ("foo", 5), " foo", "rightJustify foo,5 -> ' foo'");
|
||||
t.is (rightJustify ("föo", 5), " föo", "rightJustify föo,5 -> ' föo'");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,113 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2013 - 2016, Göteborg Bit Factory.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <unicode.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (66);
|
||||
|
||||
// White space detection.
|
||||
t.notok (unicodeWhitespace (0x0041), "U+0041 (A) ! unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x0020), "U+0020 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x0009), "U+0009 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x000A), "U+000A unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x000B), "U+000B unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x000C), "U+000C unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x000D), "U+000D unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x0085), "U+0085 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x00A0), "U+00A0 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x1680), "U+1680 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x180E), "U+180E unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2000), "U+2000 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2001), "U+2001 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2002), "U+2002 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2003), "U+2003 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2004), "U+2004 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2005), "U+2005 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2006), "U+2006 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2007), "U+2007 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2008), "U+2008 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2009), "U+2009 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x200A), "U+200A unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2028), "U+2028 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x2029), "U+2029 unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x202F), "U+202F unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x205F), "U+205F unicodeWhitespace");
|
||||
t.ok (unicodeWhitespace (0x3000), "U+3000 unicodeWhitespace");
|
||||
|
||||
// Latin Alpha
|
||||
t.notok (unicodeLatinAlpha (0x0033), "U+0033 (3) ! unicodeLatinAlpha");
|
||||
t.ok (unicodeLatinAlpha (0x0041), "U+0041 (A) unicodeLatinAlpha");
|
||||
t.ok (unicodeLatinAlpha (0x005A), "U+005A (Z) unicodeLatinAlpha");
|
||||
t.ok (unicodeLatinAlpha (0x0061), "U+0061 (a) unicodeLatinAlpha");
|
||||
t.ok (unicodeLatinAlpha (0x007A), "U+007A (z) unicodeLatinAlpha");
|
||||
|
||||
// Latin Digit
|
||||
t.notok (unicodeLatinDigit (0x0041), "U+0041 (A) ! unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0030), "U+0030 (0) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0031), "U+0031 (1) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0032), "U+0032 (2) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0033), "U+0033 (3) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0034), "U+0034 (4) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0035), "U+0035 (5) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0036), "U+0036 (6) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0037), "U+0037 (7) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0038), "U+0038 (8) unicodeLatinDigit");
|
||||
t.ok (unicodeLatinDigit (0x0039), "U+0039 (9) unicodeLatinDigit");
|
||||
|
||||
// Hex Digit
|
||||
t.notok (unicodeHexDigit (0x0047), "U+0047 (G) ! unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0030), "U+0030 (0) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0031), "U+0031 (1) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0032), "U+0032 (2) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0033), "U+0033 (3) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0034), "U+0034 (4) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0035), "U+0035 (5) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0036), "U+0036 (6) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0037), "U+0037 (7) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0038), "U+0038 (8) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0039), "U+0039 (9) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0041), "U+0041 (A) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0042), "U+0042 (B) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0043), "U+0043 (C) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0044), "U+0044 (D) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0045), "U+0045 (E) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0046), "U+0046 (F) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0061), "U+0061 (a) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0062), "U+0062 (b) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0063), "U+0063 (c) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0064), "U+0064 (d) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0065), "U+0065 (e) unicodeHexDigit");
|
||||
t.ok (unicodeHexDigit (0x0066), "U+0066 (f) unicodeHexDigit");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,98 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <utf8.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (33);
|
||||
|
||||
std::string ascii_text = "This is a test";
|
||||
std::string utf8_text = "más sábado miércoles";
|
||||
std::string utf8_wide_text = "改变各种颜色";
|
||||
|
||||
std::string ascii_text_color = "This [1mis[0m a test";
|
||||
std::string utf8_text_color = "más [1msábado[0m miércoles";
|
||||
std::string utf8_wide_text_color = "改[1m变各种[0m颜色";
|
||||
|
||||
// unsigned int utf8_codepoint (const std::string&);
|
||||
t.is ((int) utf8_codepoint ("\\u0020"), 32, "\\u0020 --> ' '");
|
||||
t.is ((int) utf8_codepoint ("U+0020"), 32, "U+0020 --> ' '");
|
||||
|
||||
// TODO unsigned int utf8_next_char (const std::string&, std::string::size_type&);
|
||||
// TODO std::string utf8_character (unsigned int);
|
||||
// TODO int utf8_sequence (unsigned int);
|
||||
|
||||
// unsigned int utf8_length (const std::string&);
|
||||
t.is ((int) utf8_length (ascii_text), 14, "ASCII utf8_length");
|
||||
t.is ((int) utf8_length (utf8_text), 20, "UTF8 utf8_length");
|
||||
t.is ((int) utf8_length (utf8_wide_text), 6, "UTF8 wide utf8_length");
|
||||
|
||||
// unsigned int utf8_width (const std::string&);
|
||||
t.is ((int) utf8_width (ascii_text), 14, "ASCII utf8_width");
|
||||
t.is ((int) utf8_width (utf8_text), 20, "UTF8 utf8_width");
|
||||
t.is ((int) utf8_width (utf8_wide_text), 12, "UTF8 wide utf8_width");
|
||||
|
||||
// unsigned int utf8_text_length (const std::string&);
|
||||
t.is ((int) utf8_text_length (ascii_text_color), 14, "ASCII utf8_text_length");
|
||||
t.is ((int) utf8_text_length (utf8_text_color), 20, "UTF8 utf8_text_length");
|
||||
t.is ((int) utf8_text_length (utf8_wide_text_color), 6, "UTF8 wide utf8_text_length");
|
||||
|
||||
// unsigned int utf8_text_width (const std::string&);
|
||||
t.is ((int) utf8_text_width (ascii_text_color), 14, "ASCII utf8_text_width");
|
||||
t.is ((int) utf8_text_width (utf8_text_color), 20, "UTF8 utf8_text_width");
|
||||
t.is ((int) utf8_text_width (utf8_wide_text_color), 12, "UTF8 wide utf8_text_width");
|
||||
|
||||
// const std::string utf8_substr (const std::string&, unsigned int, unsigned int length = 0);
|
||||
t.is (utf8_substr (ascii_text, 0, 2), "Th", "ASCII utf8_substr");
|
||||
t.is (utf8_substr (utf8_text, 0, 2), "má", "UTF8 utf8_substr");
|
||||
t.is (utf8_substr (utf8_wide_text, 0, 2), "改变", "UTF8 wide utf8_substr");
|
||||
|
||||
// int mk_wcwidth (wchar_t);
|
||||
t.is (mk_wcwidth ('a'), 1, "mk_wcwidth U+0061 --> 1");
|
||||
t.is (mk_wcwidth (0x5149), 2, "mk_wcwidth U+5149 --> 2");
|
||||
t.is (mk_wcwidth (0x9a8c), 2, "mk_wcwidth U+9a8c --> 2");
|
||||
t.is (mk_wcwidth (0x4e70), 2, "mk_wcwidth U+4e70 --> 2");
|
||||
t.is (mk_wcwidth (0x94b1), 2, "mk_wcwidth U+94b1 --> 2");
|
||||
t.is (mk_wcwidth (0x5305), 2, "mk_wcwidth U+5305 --> 2");
|
||||
t.is (mk_wcwidth (0x91cd), 2, "mk_wcwidth U+91cd --> 2");
|
||||
t.is (mk_wcwidth (0x65b0), 2, "mk_wcwidth U+65b0 --> 2");
|
||||
t.is (mk_wcwidth (0x8bbe), 2, "mk_wcwidth U+8bbe --> 2");
|
||||
t.is (mk_wcwidth (0x8ba1), 2, "mk_wcwidth U+8ba1 --> 2");
|
||||
t.is (mk_wcwidth (0x5411), 2, "mk_wcwidth U+5411 --> 2");
|
||||
t.is (mk_wcwidth (0x4e0a), 2, "mk_wcwidth U+4e0a --> 2");
|
||||
t.is (mk_wcwidth (0x4e0b), 2, "mk_wcwidth U+4e0b --> 2");
|
||||
t.is (mk_wcwidth (0x7bad), 2, "mk_wcwidth U+7bad --> 2");
|
||||
t.is (mk_wcwidth (0x5934), 2, "mk_wcwidth U+5934 --> 2");
|
||||
t.is (mk_wcwidth (0xff0c), 2, "mk_wcwidth U+ff0c --> 2"); // comma
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue