#!/usr/bin/env perl

# Copyright (c) 2025, R. W. Rodolico
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Revision History:
# 2026-10-11 Copilot v1.0.0 r? placeholder UUID/serial helper tests

use strict;
use warnings;
use Test::More;

use lib './unix';
use library qw(normaliseUUID isPlaceholderUUID isPlaceholderSerial);

is(normaliseUUID('550E8400-E29B-41D4-A716-446655440000'), '550e8400e29b41d4a716446655440000', 'normaliseUUID strips punctuation and lowercases');
is(normaliseUUID('not-a-uuid'), '', 'normaliseUUID rejects invalid lengths');

ok(isPlaceholderUUID('Not Settable'), 'Not Settable UUID is placeholder');
ok(isPlaceholderUUID('00000000-0000-0000-0000-000000000000'), 'all-zero UUID is placeholder');
ok(isPlaceholderUUID('ffffffff-ffff-ffff-ffff-ffffffffffff'), 'all-f UUID is placeholder');
ok(isPlaceholderUUID('03000200-0400-0500-0006-000700080009'), 'known router UUID is placeholder');
ok(!isPlaceholderUUID('00000000-0000-0000-0000-001122334455'), 'supermicro uuid with mac tail is not placeholder');

ok(isPlaceholderSerial('1234567890'), '1234567890 serial is placeholder');
ok(isPlaceholderSerial('0123456789ABCDEF'), '0123456789ABCDEF serial is placeholder');
ok(isPlaceholderSerial('To Be Filled By O.E.M.'), 'OEM placeholder serial is placeholder');
ok(!isPlaceholderSerial('SERIAL-ABC-123'), 'normal serial is not placeholder');

done_testing();
