PERF_TEST_F(NormalizationBasicLatin, NFKDStatic)
{
	char o[1024] = { 0 };
	size_t ol = 1023;
	int32_t e;

	size_t l = utf8normalize(m_input.c_str(), m_input.length(), o, ol, UTF8_NORMALIZE_DECOMPOSE | UTF8_NORMALIZE_COMPATIBILITY, &e);

	PERF_ASSERT(l > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);
}
PERF_TEST_F(NormalizationBasicMultilingualPlane, NFKCStatic)
{
	char o[MAX_BASIC_MULTILINGUAL_PLANE * 4] = { 0 };
	size_t ol = MAX_BASIC_MULTILINGUAL_PLANE * 4 - 1;
	int32_t e;

	size_t l = utf8normalize(m_input.c_str(), m_input.length(), o, ol, UTF8_NORMALIZE_COMPOSE | UTF8_NORMALIZE_COMPATIBILITY, &e);

	PERF_ASSERT(l > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);
}
PERF_TEST_F(NormalizationLatin1, NFKCStatic)
{
	char o[MAX_LATIN_1 * 4] = { 0 };
	size_t ol = MAX_LATIN_1 * 4 - 1;
	int32_t e;

	size_t l = utf8normalize(m_input.c_str(), m_input.length(), o, ol, UTF8_NORMALIZE_COMPOSE | UTF8_NORMALIZE_COMPATIBILITY, &e);

	PERF_ASSERT(l > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);
}
PERF_TEST_F(GreekSeeking, CurrentForwards)
{
	const char* s = m_contents.c_str();

	const char* n = utf8seek(s, m_contents.length(), s, (off_t)utf8len(s) - 1, SEEK_CUR);
	PERF_ASSERT(n == s + m_contents.length() - 1);
}
PERF_TEST_F(GreekSeeking, Begin)
{
	const char* s = m_contents.c_str();

	const char* n = utf8seek(s, m_contents.length(), s, (off_t)utf8len(s) - 1, SEEK_SET);
	PERF_ASSERT(n == s + m_contents.length() - 1);
}
PERF_TEST_F(GreekSeeking, End)
{
	const char* s = m_contents.c_str();
	const char* e = s + m_contents.length();

	const char* n = utf8seek(e, m_contents.length(), s, (off_t)utf8len(s) - 1, SEEK_END);
	PERF_ASSERT(n == s + 1);
}
PERF_TEST_F(GreekSeeking, CurrentBackwards)
{
	const char* s = m_contents.c_str();
	const char* e = s + m_contents.length();

	const char* n = utf8seek(e, m_contents.length(), s, -(off_t)utf8len(s) + 1, SEEK_CUR);
	PERF_ASSERT(n == s + 1);
}
Ejemplo n.º 8
0
NTSTATUS
PerfInfoReserveBytes(
    PPERFINFO_HOOK_HANDLE Hook,
    USHORT HookId,
    ULONG BytesToReserve
    )
/*++

Routine Description:

    Reserves memory for the hook via WMI and initializes the header.

Arguments:

    Hook - pointer to hook handle (used for reference decrement)
    HookId - Id for the hook
    BytesToLog - size of data in bytes

Return Value:

    STATUS_SUCCESS on success
    STATUS_UNSUCCESSFUL if the buffer memory couldn't be allocated.
--*/
{
    NTSTATUS Status = STATUS_UNSUCCESSFUL;
    PPERFINFO_TRACE_HEADER PPerfTraceHeader = NULL;
    PWMI_BUFFER_HEADER PWmiBufferHeader = NULL;

    PERF_ASSERT((BytesToReserve + FIELD_OFFSET(PERFINFO_TRACE_HEADER, Data)) <= MAXUSHORT);
    PERF_ASSERT(Hook != NULL);

    PPerfTraceHeader = WmiReserveWithPerfHeader(BytesToReserve, &PWmiBufferHeader);

    if (PPerfTraceHeader != NULL) {
        PPerfTraceHeader->Packet.HookId = HookId;
        Hook->PerfTraceHeader = PPerfTraceHeader;
        Hook->WmiBufferHeader = PWmiBufferHeader;

        Status = STATUS_SUCCESS;
    } else {
        *Hook = PERF_NULL_HOOK_HANDLE;
    }

    return Status;
}
PERF_TEST_F(BigConversion, Utf32)
{
	int32_t e;

	size_t ol = utf8toutf32(m_contents.c_str(), m_contents.length(), nullptr, 0, &e);

	PERF_ASSERT(ol > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);

	if (ol > 0 &&
		e == UTF8_ERR_NONE)
	{
		unicode_t* o = new unicode_t[(ol / sizeof(unicode_t)) + 1];
		memset(o, 0, ol + sizeof(unicode_t));

		utf8toutf32(m_contents.c_str(), m_contents.length(), o, ol, nullptr);

		delete [] o;
	}
}
PERF_TEST_F(NormalizationBasicLatin, NFCDynamic)
{
	int32_t e;

	size_t ol = utf8normalize(m_input.c_str(), m_input.length(), nullptr, 0, UTF8_NORMALIZE_COMPOSE, &e);

	PERF_ASSERT(ol > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);

	if (ol > 0 &&
		e == UTF8_ERR_NONE)
	{
		char* o = new char[ol + 1];
		memset(o, 0, ol + 1);

		utf8normalize(m_input.c_str(), m_input.length(), o, ol, UTF8_NORMALIZE_COMPOSE, nullptr);

		delete [] o;
	}
}
PERF_TEST_F(NormalizationBasicMultilingualPlane, NFKDDynamic)
{
	int32_t e;

	size_t ol = utf8normalize(m_input.c_str(), m_input.length(), nullptr, 0, UTF8_NORMALIZE_DECOMPOSE | UTF8_NORMALIZE_COMPATIBILITY, &e);

	PERF_ASSERT(ol > 0);
	PERF_ASSERT(e == UTF8_ERR_NONE);

	if (ol > 0 &&
		e == UTF8_ERR_NONE)
	{
		char* o = new char[ol + 1];
		memset(o, 0, ol + 1);

		utf8normalize(m_input.c_str(), m_input.length(), o, ol, UTF8_NORMALIZE_DECOMPOSE | UTF8_NORMALIZE_COMPATIBILITY, nullptr);

		delete [] o;
	}
}
Ejemplo n.º 12
0
	virtual void setup() override
	{
		std::fstream stream("testdata/big.txt", std::ios_base::in);
		PERF_ASSERT(stream.is_open());
		if (!stream.is_open())
		{
			return;
		}

		std::stringstream ss;
		ss << stream.rdbuf();

		m_contents = ss.str();

		stream.close();
	}
PERF_TEST_F(GreekSeeking, IncrementalBackwards)
{
	const char* s = m_contents.c_str();
	const char* e = s + m_contents.length();
	const char* c = e;
	const char* n = c;
	size_t l = m_contents.length();

	do
	{
		c = n;
		n = utf8seek(c, l, s, -1, SEEK_CUR);
	}
	while (n != c && n != s);

	PERF_ASSERT(n == s);
}