This commit is contained in:
n0ffie 2025-02-12 23:24:58 +01:00
parent 2dbfa1b99e
commit b1230534c5
22 changed files with 547 additions and 429 deletions

View file

@ -1,86 +0,0 @@
//
// Created by n0ffie on 10/02/2025.
//
#include <alyson.h>
#include <stdio.h>
int main(int argc, char** argv)
{
ALPath path = al_demangle_path("res://test:/test.png");
printf("1. %s\n", al_mangle_path(path));
al_destroy_path(path);
fflush(stdout);
fflush(stderr);
path = al_demangle_path("res://image/test:/gay/test.png");
printf("2. %s\n", al_mangle_path(path));
al_destroy_path(path);
fflush(stdout);
fflush(stderr);
path = al_demangle_path("res:/test:/test.png");
if (path != NULL)
{
printf("3. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
path = al_demangle_path("://test:/test.png");
if (path != NULL)
{
printf("4. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
path = al_demangle_path("img://:/test.png");
if (path != NULL)
{
printf("6. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
path = al_demangle_path("://:a");
if (path != NULL)
{
printf("7. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
path = al_demangle_path("g://a:");
if (path != NULL)
{
printf("8. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
path = al_demangle_path("image://gay/guy:/a/b");
if (path != NULL)
{
printf("9. %s\n", al_mangle_path(path));
al_destroy_path(path);
}
fflush(stdout);
fflush(stderr);
return 0;
}

65
alyson/tests/ALPath.cpp Normal file
View file

@ -0,0 +1,65 @@
//
// Created by n0ffie on 10/02/2025.
//
#include <alyson.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// gtests
#include <gtest/gtest.h>
bool test_path(const char* path)
{
if (path == NULL)
return false;
ALPath al_path = al_demangle_path(path);
if (al_path == NULL)
return false;
if (al_path->path == NULL)
return false;
printf("Path: %s\n", al_path->path);
char* string = al_mangle_path(al_path);
if (strcmp(string, path) != 0) {
printf("%s : %s\n", path, string);
return false;
}
printf("\t%s\n", string);
free(string);
al_destroy_path(al_path);
return true;
}
void pathEQ_test(const char* string) {
ALPath al_path = al_demangle_path(string);
char* s2 = al_mangle_path(al_path);
EXPECT_STREQ(string, s2);
free(s2);
al_destroy_path(al_path);
}
TEST(PathEqual, normal) {
pathEQ_test("res://normal:path/this.is");
}
TEST(PathEqual, group_long_type) {
pathEQ_test("gays://i/love:gays/iam.one/kind.of");
}
TEST(PathEqual, group_type) {
pathEQ_test("g/es://this/is:shit");
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}