#include <stic.h>
#include <stdlib.h> /* free() */
#include <string.h> /* memset() */
#include "../../src/engine/parsing.h"
#include "../../src/engine/var.h"
#include "asserts.h"
TEST(negative_number_ok)
{
ASSERT_OK("-1", "-1");
}
TEST(multiple_negations_ok)
{
ASSERT_OK("--1", "1");
ASSERT_OK("---1", "-1");
ASSERT_OK("----1", "1");
ASSERT_OK("-----1", "-1");
}
TEST(spaces_betwen_signs_ok)
{
ASSERT_OK("--- 1", "-1");
ASSERT_OK("- - + 1", "1");
ASSERT_OK(" ++ + 1", "1");
}
TEST(zero_ok)
{
ASSERT_OK("0", "0");
ASSERT_OK("-0", "0");
ASSERT_OK("+0", "0");
}
TEST(multiple_zeroes_ok)
{
ASSERT_OK("00000", "0");
ASSERT_OK("-00000", "0");
ASSERT_OK("+00000", "0");
}
TEST(positive_number_ok)
{
ASSERT_OK("12345", "12345");
ASSERT_OK("+12", "12");
ASSERT_OK("++12", "12");
ASSERT_OK("+++12", "12");
}
TEST(leading_zeroes_ok)
{
ASSERT_OK("0123456", "123456");
}
TEST(single_signs_fail)
{
ASSERT_FAIL("-", PE_INVALID_EXPRESSION);
ASSERT_FAIL("--", PE_INVALID_EXPRESSION);
ASSERT_FAIL("+", PE_INVALID_EXPRESSION);
ASSERT_FAIL("++", PE_INVALID_EXPRESSION);
ASSERT_FAIL("- +", PE_INVALID_EXPRESSION);
ASSERT_FAIL("+ -", PE_INVALID_EXPRESSION);
}
TEST(string_is_converted_for_signs)
{
ASSERT_OK("-'a'", "0");
ASSERT_OK("+'a'", "0");
ASSERT_OK("-'1'", "-1");
ASSERT_OK("-'0'", "0");
ASSERT_OK("-''", "0");
ASSERT_OK("-'-1'", "1");
ASSERT_OK("-'--1'", "0");
ASSERT_OK("+'10'", "10");
ASSERT_OK("+'-100'", "-100");
}
TEST(extremely_long_number)
{
char zeroes[8192];
memset(zeroes, '0', sizeof(zeroes) - 1U);
zeroes[sizeof(zeroes) - 1U] = '\0';
ASSERT_FAIL(zeroes, PE_INTERNAL);
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */
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