json-c: add test (#12168)
This commit is contained in:
parent
2de7394271
commit
895222365d
1 changed files with 17 additions and 0 deletions
|
@ -31,4 +31,21 @@ class JsonC < Formula
|
|||
ENV.deparallelize
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.c").write <<-'EOS'.undent
|
||||
#include <stdio.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
int main() {
|
||||
json_object *obj = json_object_new_object();
|
||||
json_object *value = json_object_new_string("value");
|
||||
json_object_object_add(obj, "key", value);
|
||||
printf("%s\n", json_object_to_json_string(obj));
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "-I#{include}", "-L#{lib}", "-ljson-c", "test.c", "-o", "test"
|
||||
assert_equal '{ "key": "value" }', shell_output("./test").chomp
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue