git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 3/3] test: add basic unit test

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 2, 2023, 04:11 UTC
Message-ID
<20230502041113.103385-4-felipe.contreras@gmail.com>
In-Reply-To
<20230502041113.103385-1-felipe.contreras@gmail.com>
We simply add that function, and test that function.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/lib/git.c   | 5 +++++
 t/lib/git.h   | 2 ++
 t/ruby/git.c  | 6 ++++++
 t/unit-test.t | 4 ++++
 4 files changed, 17 insertions(+)
diff --git a/t/lib/git.c b/t/lib/git.c
index 40d96ee354..54206171cb 100644
--- a/t/lib/git.c
+++ b/t/lib/git.c
@@ -1 +1,6 @@
 #include <git.h>
+
+int ok(void)
+{
+	return 1;
+}
diff --git a/t/lib/git.h b/t/lib/git.h
index 58a28085f5..dbbac9e406 100644
--- a/t/lib/git.h
+++ b/t/lib/git.h
@@ -1,4 +1,6 @@
 #ifndef GIT_H
 #define GIT_H
 
+int ok(void);
+
 #endif /* GIT_H */
diff --git a/t/ruby/git.c b/t/ruby/git.c
index e75692c582..e173dfe03d 100644
--- a/t/ruby/git.c
+++ b/t/ruby/git.c
@@ -1,7 +1,13 @@
 #include <ruby.h>
 #include <git.h>
 
+VALUE rb_ok(VALUE self)
+{
+	return RTEST(ok());
+}
+
 void Init_git(void)
 {
 	VALUE mod = rb_define_module("Git");
+	rb_define_singleton_method(mod, "ok", rb_ok, 0);
 }
diff --git a/t/unit-test.t b/t/unit-test.t
index 97d8a14ec3..27303f9c49 100644
--- a/t/unit-test.t
+++ b/t/unit-test.t
@@ -7,4 +7,8 @@ test 'basic' do
   ok(true)
 end
 
+test 'ok' do
+  ok(Git::ok())
+end
+
 # vim: ft=ruby
-- 
2.40.0+fc1
Previous: Felipe Contreras
Message 4 of 4 in “test: new testing framework for libification”
  1. 0/3 test: new testing framework for libificationFelipe Contreras, May 2, 2023
  2. 1/3 test: add simple shared libraryFelipe Contreras, May 2, 2023
  3. 2/3 test: add basic unit testing frameworkFelipe Contreras, May 2, 2023
  4. 3/3 test: add basic unit testFelipe Contreras, May 2, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.