MCPcopy Create free account
hub / github.com/creatale/node-dv / regTestWriteDataAndCheck

Function regTestWriteDataAndCheck

deps/leptonica/src/regutils.c:769–797  ·  view source on GitHub ↗

! * \brief regTestWriteDataAndCheck() * * \param[in] rp regtest parameters * \param[in] data to be written * \param[in] size of data to be written * \param[in] ext filename extension (e.g.: "ba", "pta") * \return 0 if OK, 1 on error a failure in comparison is not an error * * * Notes: * (1) This function makes it easy to write data in a numbered

Source from the content-addressed store, hash-verified

767 * </pre>
768 */
769l_int32
770regTestWriteDataAndCheck(L_REGPARAMS *rp,
771 void *data,
772 size_t nbytes,
773 const char *ext)
774{
775char namebuf[256];
776
777 PROCNAME("regTestWriteDataAndCheck");
778
779 if (!rp)
780 return ERROR_INT("rp not defined", procName, 1);
781 if (!data || nbytes == 0) {
782 rp->success = FALSE;
783 return ERROR_INT("data not defined or size == 0", procName, 1);
784 }
785
786 /* Generate the local file name */
787 snprintf(namebuf, sizeof(namebuf), "/tmp/lept/regout/%s.%02d.%s",
788 rp->testname, rp->index + 1, ext);
789
790 /* Write the local file */
791 l_binaryWrite(namebuf, "w", data, nbytes);
792
793 /* Either write the golden file ("generate") or check the
794 local file against an existing golden file ("compare") */
795 regTestCheckFile(rp, namebuf);
796 return 0;
797}
798
799
800/*!

Callers

nothing calls this directly

Calls 2

l_binaryWriteFunction · 0.85
regTestCheckFileFunction · 0.85

Tested by

no test coverage detected