// Standalone teaching example, not Trace source or a product qualification. // Requirement: contain at least one character other than ASCII space U+0020. // This demonstrates a deliberately incomplete length-only implementation. #include #include bool valid_name(std::string_view value) { return !value.empty(); } int main() { struct Case { const char* label; std::string_view input; bool required; }; constexpr Case cases[] = { {"ordinary", "example", true}, {"empty", "", false}, {"three ASCII spaces", " ", false} }; int mismatches = 0; std::cout << std::boolalpha; for (const auto& item : cases) { const bool observed = valid_name(item.input); std::cout << item.label << ": observed=" << observed << ", required=" << item.required << '\n'; if (observed != item.required) ++mismatches; } std::cout << "Requirement mismatches: " << mismatches << " of 3\n"; // Success means the teaching example reproduced its one expected defect. return mismatches == 1 ? 0 : 1; }