<commit_before>// Copyright 2008-present Contributors to the OpenImageIO project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md

/////////////////////////////////////////////////////////////////////////
// Tests related to ImageInput and ImageOutput
/////////////////////////////////////////////////////////////////////////

#include <iostream>

#include <OpenImageIO/benchmark.h>
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/imagebufalgo.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/unittest.h>

using namespace OIIO;



// Generate a small test image appropriate to the given format
static ImageBuf
make_test_image(string_view formatname)
{
    ImageBuf buf;
    auto out = ImageOutput::create(formatname);
    ASSERT(out);
    if (formatname == "zfile" || formatname == "fits")
        buf.reset(ImageSpec(64, 64, 1, TypeFloat));
    else if (!out->supports("alpha"))
        buf.reset(ImageSpec(64, 64, 3, TypeFloat));
    else
        buf.reset(ImageSpec(64, 64, 4, TypeFloat));
    ImageBufAlgo::fill(buf, { 1.0f, 1.0f, 1.0f, 1.0f });
    return buf;
}



#define CHECKED(obj, call)                                                     \
    if (!obj->call) {                                                          \
        if (do_asserts)                                                        \
            OIIO_CHECK_ASSERT(false && #call);                                 \
        if (errmsg)                                                            \
            *errmsg = obj->geterror();                                         \<commit_msg>Fix occasional CI failure in imageinout_test (#2420)<commit_after>// Copyright 2008-present Contributors to the OpenImageIO project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md

/////////////////////////////////////////////////////////////////////////
// Tests related to ImageInput and ImageOutput
/////////////////////////////////////////////////////////////////////////

#include <iostream>

#include <OpenImageIO/benchmark.h>
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/imagebufalgo.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/unittest.h>

using namespace OIIO;



// Generate a small test image appropriate to the given format
static ImageBuf
make_test_image(string_view formatname)
{
    ImageBuf buf;
    auto out = ImageOutput::create(formatname);
    ASSERT(out);
    ImageSpec spec(64, 64, 4, TypeFloat);
    if (formatname == "zfile" || formatname == "fits")
        spec.nchannels = 1;  // these formats are single channel
    else if (!out->supports("alpha"))
        spec.nchannels = 3;  // this channel doesn't support alpha
    // Force a fixed datetime metadata so it can't differ between writes
    // and make different file patterns for these tests.
    spec.attribute("DateTime", "01/01/2000 00:00:00");
    buf.reset(spec);
    ImageBufAlgo::fill(buf, { 1.0f, 1.0f, 1.0f, 1.0f });
    return buf;
}



#define CHECKED(obj, call)                                                     \
    if (!obj->call) {                                                          \
        if (do_asserts)                                                        \
            OIIO_CHECK_ASSERT(false && #call);                                 \
        if (errmsg)                                                            \
            *errmsg = obj->geterror();                                         \
{'fraction_non_alphanumeric': 0.1824736550194121, 'fraction_numerical': 0.018302828618968387, 'mean_word_length': 1.3950863213811422, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6330328', 'n_tokens_mistral': 965, 'n_tokens_neox': 905, 'n_words': 225}