-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AI TestGen LLM #4
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an example of the output generated, pre-processed and then diff'ed against the original code: --- ../../sparky/test/src/sk_hashmap_test.c 2024-06-12 21:23:57.397377883 +0200
+++ tmp.cc 2024-07-20 21:21:17.035844090 +0200
@@ -1,45 +1,35 @@
-/*
- * GNU Sparky --- A 5v5 character-based libre tactical shooter
- * Copyright (C) 2024 Wasym A. Alonso
- *
- * This file is part of Sparky.
- *
- * Sparky is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Sparky is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Sparky. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
#include <carbon.h>
#include <sk_hashmap.h>
#include <sk_hashmap_test.h>
-static u8 sk_hashmap_test_create_destroy(void) {
+static u8 sk_hashmap_test_set_get_element_invalid_input(void) {
sk_hashmap x = sk_hashmap_create(2 << 1, sizeof(int));
- carbon_should_be(2 << 1, x.capacity);
- carbon_should_be(sizeof(int), x.element_size);
- carbon_should_be_true(x.data);
+ int i = 7, j;
+ carbon_should_be_false(sk_hashmap_set(&x, NULL, &i));
+ carbon_should_be_false(sk_hashmap_set(&x, "seven", NULL));
+ carbon_should_be_false(sk_hashmap_get(&x, NULL, &j));
+ carbon_should_be_false(sk_hashmap_get(&x, "seven", NULL));
sk_hashmap_destroy(&x);
- carbon_should_be(0, x.capacity);
- carbon_should_be(0, x.element_size);
- carbon_should_be_p(0, x.data);
return 1;
}
-static u8 sk_hashmap_test_set_get_element(void) {
+static u8 sk_hashmap_test_set_get_element_collision(void) {
sk_hashmap x = sk_hashmap_create(2 << 1, sizeof(int));
int i = 7, j;
carbon_should_be_true(sk_hashmap_set(&x, "seven", &i));
- carbon_should_be_true(sk_hashmap_get(&x, "seven", &j));
+ carbon_should_be_true(sk_hashmap_set(&x, "seventeen", &j));
+ carbon_should_be(j, *((int *) x.data + hash("seventeen", x.capacity)));
+ sk_hashmap_destroy(&x);
+ return 1;
+}
+
+static u8 sk_hashmap_test_set_get_element_large_data(void) {
+ sk_hashmap x = sk_hashmap_create(2 << 1, sizeof(int));
+ int i = 7, j;
+ char large_data[1024];
+ memset(large_data, 'a', sizeof(large_data));
+ carbon_should_be_true(sk_hashmap_set(&x, large_data, &i));
+ carbon_should_be_true(sk_hashmap_get(&x, large_data, &j));
carbon_should_be(i, j);
sk_hashmap_destroy(&x);
return 1;
@@ -48,4 +38,7 @@
void sk_hashmap_test_register(void) {
CARBON_REGISTER_TEST(sk_hashmap_test_create_destroy);
CARBON_REGISTER_TEST(sk_hashmap_test_set_get_element);
+ CARBON_REGISTER_TEST(sk_hashmap_test_set_get_element_invalid_input);
+ CARBON_REGISTER_TEST(sk_hashmap_test_set_get_element_collision);
+ CARBON_REGISTER_TEST(sk_hashmap_test_set_get_element_large_data);
} As can be seen, it generated 3 new tests, but didn't leave the original code intact (it nuked 'em all 😆). Will continue working on it, but it's quite stable for now, so all its dev will be in the |
iWas-Coder
force-pushed
the
feature/testgen
branch
from
July 20, 2024 19:28
30d9df5
to
6342d77
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original paper: https://arxiv.org/pdf/2402.09171