xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
<root> / tests / utils / str_to_case.c (7b46e3f17694ece7d70375c4d1477b73274ac1a2) (2,607B) (mode 100644) [raw]
#include <stic.h>

#include <test-utils.h>

#include "../../src/utils/str.h"

SETUP_ONCE()
{
	try_enable_utf8_locale();
}

TEST(str_to_upper_ascii)
{
	char str[] = "aBcDeF";
	char buf[sizeof(str)*4];

	assert_success(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("ABCDEF", buf);
}

TEST(str_to_upper_utf, IF(utf8_locale))
{
	char str[] = "??????";
	char buf[sizeof(str)*4];

	assert_success(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("??????", buf);
}

TEST(str_to_upper_mixed, IF(utf8_locale))
{
	char str[] = "?a?b?c?d?e?f";
	char buf[sizeof(str)*4];

	assert_success(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("?A?B?C?D?E?F", buf);
}

TEST(str_to_lower_ascii)
{
	char str[] = "aBcDeF";
	char buf[sizeof(str)*4];

	assert_success(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("abcdef", buf);
}

TEST(str_to_lower_utf, IF(utf8_locale))
{
	char str[] = "??????";
	char buf[sizeof(str)*4];

	assert_success(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("??????", buf);
}

TEST(str_to_lower_mixed, IF(utf8_locale))
{
	char str[] = "?a?b?c?d?e?f";
	char buf[sizeof(str)*4];

	assert_success(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("?a?b?c?d?e?f", buf);
}

TEST(str_to_lower_too_short_ascii)
{
	char str[] = "abcdef";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("abcde", buf);
}

TEST(str_to_upper_too_short_ascii)
{
	char str[] = "abcdef";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("ABCDE", buf);
}

TEST(str_to_lower_too_short_utf, IF(utf8_locale))
{
	char str[] = "????";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("???", buf);
}

TEST(str_to_upper_too_short_utf, IF(utf8_locale))
{
	char str[] = "????";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("???", buf);
}

TEST(str_to_lower_too_short_mixed, IF(utf8_locale))
{
	char str[] = "?a?b?c?d";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_lower(str, buf, sizeof(buf)));
	assert_string_equal("?a?b?c?", buf);
}

TEST(str_to_upper_too_short_mixed, IF(utf8_locale))
{
	char str[] = "?a?b?c?d";
	char buf[sizeof(str) - 1];

	assert_failure(str_to_upper(str, buf, sizeof(buf)));
	assert_string_equal("?A?B?C?", buf);
}

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master