Revert "Add nix::isASCII*, locale-independent"

This reverts commit 79eb2920bb.

Not used at this time.

(cherry picked from commit 0b87ba50c0)
This commit is contained in:
Robert Hensing 2023-12-12 17:44:53 +01:00
parent ebdb6926fd
commit 01cf57703a
2 changed files with 0 additions and 76 deletions

View File

@ -1,17 +0,0 @@
#pragma once
namespace nix {
/** Locale-independent version of std::islower(). */
inline bool isASCIILower(char c) { return c >= 'a' && c <= 'z'; };
/** Locale-independent version of std::isupper(). */
inline bool isASCIIUpper(char c) { return c >= 'A' && c <= 'Z'; };
/** Locale-independent version of std::isalpha(). */
inline bool isASCIIAlpha(char c) { return isASCIILower(c) || isASCIIUpper(c); };
/** Locale-independent version of std::isdigit(). */
inline bool isASCIIDigit(char c) { return c >= '0' && c <= '9'; };
}

View File

@ -1,59 +0,0 @@
#include <gtest/gtest.h>
#include "string.hh"
namespace nix {
TEST(string, isASCIILower) {
ASSERT_TRUE(isASCIILower('a'));
ASSERT_TRUE(isASCIILower('z'));
ASSERT_FALSE(isASCIILower('A'));
ASSERT_FALSE(isASCIILower('Z'));
ASSERT_FALSE(isASCIILower('0'));
ASSERT_FALSE(isASCIILower('9'));
ASSERT_FALSE(isASCIILower(' '));
ASSERT_FALSE(isASCIILower('\n'));
ASSERT_FALSE(isASCIILower('\t'));
ASSERT_FALSE(isASCIILower(':'));
}
TEST(string, isASCIIUpper) {
ASSERT_FALSE(isASCIIUpper('a'));
ASSERT_FALSE(isASCIIUpper('z'));
ASSERT_TRUE(isASCIIUpper('A'));
ASSERT_TRUE(isASCIIUpper('Z'));
ASSERT_FALSE(isASCIIUpper('0'));
ASSERT_FALSE(isASCIIUpper('9'));
ASSERT_FALSE(isASCIIUpper(' '));
ASSERT_FALSE(isASCIIUpper('\n'));
ASSERT_FALSE(isASCIIUpper('\t'));
ASSERT_FALSE(isASCIIUpper(':'));
}
TEST(string, isASCIIAlpha) {
ASSERT_TRUE(isASCIIAlpha('a'));
ASSERT_TRUE(isASCIIAlpha('z'));
ASSERT_TRUE(isASCIIAlpha('A'));
ASSERT_TRUE(isASCIIAlpha('Z'));
ASSERT_FALSE(isASCIIAlpha('0'));
ASSERT_FALSE(isASCIIAlpha('9'));
ASSERT_FALSE(isASCIIAlpha(' '));
ASSERT_FALSE(isASCIIAlpha('\n'));
ASSERT_FALSE(isASCIIAlpha('\t'));
ASSERT_FALSE(isASCIIAlpha(':'));
}
TEST(string, isASCIIDigit) {
ASSERT_FALSE(isASCIIDigit('a'));
ASSERT_FALSE(isASCIIDigit('z'));
ASSERT_FALSE(isASCIIDigit('A'));
ASSERT_FALSE(isASCIIDigit('Z'));
ASSERT_TRUE(isASCIIDigit('0'));
ASSERT_TRUE(isASCIIDigit('1'));
ASSERT_TRUE(isASCIIDigit('9'));
ASSERT_FALSE(isASCIIDigit(' '));
ASSERT_FALSE(isASCIIDigit('\n'));
ASSERT_FALSE(isASCIIDigit('\t'));
ASSERT_FALSE(isASCIIDigit(':'));
}
}