.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::RDF 3pm" .TH Test::RDF 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Test::RDF \- Test RDF data for content, validity and equality, etc. .SH VERSION .IX Header "VERSION" Version 1.22 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Test::RDF; \& \& is_valid_rdf($rdf_string, $syntax, \*(AqRDF string is valid according to selected syntax\*(Aq); \& is_rdf($rdf_string, $syntax1, $expected_rdf_string, $syntax2, \*(AqThe two strings have the same triples\*(Aq); \& isomorph_graphs($model, $expected_model, \*(AqThe two models have the same triples\*(Aq); \& are_subgraphs($model1, $model2, \*(AqModel 1 is a subgraph of model 2\*(Aq ); \& has_uri($uri_string, $model, \*(AqHas correct URI\*(Aq); \& hasnt_uri($uri_string, $model, "Hasn\*(Aqt correct URI"); \& has_subject($uri_string, $model, \*(AqSubject URI is found\*(Aq); \& has_predicate($uri_string, $model, \*(AqPredicate URI is found\*(Aq); \& has_object_uri($uri_string, $model, \*(AqObject URI is found\*(Aq); \& has_type($uri_string, $model, \*(AqClass URI is found\*(Aq); \& has_literal($string, $language, $datatype, $model, \*(AqLiteral is found\*(Aq); \& hasnt_literal($string, $language, $datatype, $model, \*(AqLiteral is not found\*(Aq); \& pattern_target($model); \& pattern_ok($pattern, \*(Aq$pattern found in $model\*(Aq); \& pattern_fail($pattern, \*(Aq$pattern not found in $model\*(Aq); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This Perl module, Test::RDF, provides tools for testing code which deals with RDF. It can test RDF for validity, check if two RDF graphs are the same, or subgraphs of each other, if a URI is or is not in a dataset, if it has certain subjects, predicates, objects or literals. It can also test to see if a full pattern is present or absent. .SH EXPORT .IX Header "EXPORT" .SS is_valid_rdf .IX Subsection "is_valid_rdf" Use to check if the input RDF string is valid in the chosen syntax .SS is_rdf .IX Subsection "is_rdf" Use to check if the input RDF strings are isomorphic (i.e. the same). .SS isomorph_graphs .IX Subsection "isomorph_graphs" Use to check if the input RDF::Trine::Models have isomorphic graphs. .SS are_subgraphs .IX Subsection "are_subgraphs" Use to check if the first RDF::Trine::Models is a subgraph of the second. .SS has_subject .IX Subsection "has_subject" Check if the string URI passed as first argument is a subject in any of the statements given in the model given as second argument. .SS has_predicate .IX Subsection "has_predicate" Check if the string URI passed as first argument is a predicate in any of the statements given in the model given as second argument. .SS has_object_uri .IX Subsection "has_object_uri" Check if the string URI passed as first argument is a object in any of the statements given in the model given as second argument. .SS has_type .IX Subsection "has_type" Check if the string URI passed as first argument is an RDF class instance in any of the statements given in the model given as second argument. .SS has_literal .IX Subsection "has_literal" Check if the string passed as first argument, with corresponding optional language and datatype as second and third respectively, is a literal in any of the statements given in the model given as fourth argument. .PP language and datatype may not occur in the same statement, so the test fails if they are both set. If none are used, use \f(CW\*(C`undef\*(C'\fR, like e.g. .PP .Vb 1 \& has_literal(\*(AqA test\*(Aq, undef, undef, $model, \*(AqSimple literal\*(Aq); .Ve .PP A test for a typed literal may be done like .PP .Vb 1 \& has_literal(\*(Aq42\*(Aq, undef, \*(Aqhttp://www.w3.org/2001/XMLSchema#integer\*(Aq, $model, \*(AqJust an integer\*(Aq); .Ve .PP and a language literal like .PP .Vb 1 \& has_literal(\*(AqThis is a Another test\*(Aq, \*(Aqen\*(Aq, undef, $model, \*(AqLanguage literal\*(Aq); .Ve .SS hasnt_literal .IX Subsection "hasnt_literal" This is like the above, only the opposite: It checks if a literal doesn't exist. Like the above, the test will fail if the literal is invalid, however. .SS has_uri .IX Subsection "has_uri" Check if the string URI passed as first argument is present in any of the statements given in the model given as second argument. .SS hasnt_uri .IX Subsection "hasnt_uri" Check if the string URI passed as first argument is not present in any of the statements given in the model given as second argument. .SS pattern_target .IX Subsection "pattern_target" Tests that the object passed as its parameter is an RDF::Trine::Model or RDF::Trine::Store. That is, tests that it is a valid thing to match basic graph patterns against. .PP Additionally, this test establishes the target for future \f(CW\*(C`pattern_ok\*(C'\fR tests. .SS pattern_ok .IX Subsection "pattern_ok" Tests that the pattern passed matches against the target established by \&\f(CW\*(C`pattern_target\*(C'\fR. The pattern may be passed as an RDF::Trine::Pattern, or a list of RDF::Trine::Statement objects. .PP .Vb 3 \& use Test::RDF; \& use RDF::Trine qw[iri literal blank variable statement]; \& use My::Module; \& \& my $foaf = RDF::Trine::Namespace\->new(\*(Aqhttp://xmlns.com/foaf/0.1/\*(Aq); \& pattern_target(My::Module\->get_model); # check isa RDF::Trine::Model \& pattern_ok( \& statement( \& variable(\*(Aqwho\*(Aq), \& $foaf\->name, \& literal(\*(AqKjetil Kjernsmo\*(Aq) \& ), \& statement( \& variable(\*(Aqwho\*(Aq), \& $foaf\->page, \& iri(\*(Aqhttp://search.cpan.org/~kjetilk/\*(Aq) \& ), \& "Data contains Kjetil\*(Aqs details." \& ); .Ve .PP \&\fBNote:\fR \f(CW\*(C`pattern_target\*(C'\fR must have been tested before any \f(CW\*(C`pattern_ok\*(C'\fR tests. .SS pattern_fail .IX Subsection "pattern_fail" The same as above, but tests if the pattern returns no results instead. .SH NOTE .IX Header "NOTE" Graph isomorphism is a complex problem, so do not attempt to run the isomorphism tests on large datasets. For more information see . .SH AUTHOR .IX Header "AUTHOR" Kjetil Kjernsmo, \f(CW\*(C`\*(C'\fR .SH BUGS .IX Header "BUGS" Please report any bugs using github .SH SUPPORT .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Test::RDF .Ve .PP You may find the Perl and RDF community website useful. .PP You can also look for information at: .IP \(bu 4 AnnoCPAN: Annotated CPAN documentation .Sp .IP \(bu 4 CPAN Ratings .Sp .IP \(bu 4 Search CPAN .Sp .IP \(bu 4 MetaCPAN .Sp .SH ACKNOWLEDGEMENTS .IX Header "ACKNOWLEDGEMENTS" Michael Hendricks wrote the first Test::RDF. The present module is a complete rewrite from scratch using Gregory Todd William's RDF::Trine::Graph to do the heavy lifting. .PP Toby Inkster has submitted the pattern_* functions. .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2010 ABC Startsiden AS. Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2017 Kjetil Kjernsmo. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. .PP See http://dev.perl.org/licenses/ for more information.