1N/A/*
1N/A * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
1N/A * All rights reserved.
1N/A *
1N/A * By using this file, you agree to the terms and conditions set
1N/A * forth in the LICENSE file which can be found at the top level of
1N/A * the sendmail distribution.
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#include <sm/gen.h>
1N/ASM_IDSTR(id, "@(#)$Id: t-string.c,v 1.9 2001/01/26 03:28:43 ca Exp $")
1N/A
1N/A#include <sm/exc.h>
1N/A#include <sm/io.h>
1N/A#include <sm/string.h>
1N/A#include <sm/test.h>
1N/A
1N/Aint
1N/Amain(argc, argv)
1N/A int argc;
1N/A char **argv;
1N/A{
1N/A char *s;
1N/A char buf[4096];
1N/A char foo[4];
1N/A char *r;
1N/A int n;
1N/A
1N/A sm_test_begin(argc, argv, "test string utilities");
1N/A
1N/A s = sm_stringf_x("%.3s%03d", "foobar", 42);
1N/A r = "foo042";
1N/A SM_TEST(strcmp(s, r) == 0);
1N/A
1N/A s = sm_stringf_x("+%*x+", 2000, 0xCAFE);
1N/A sm_snprintf(buf, 4096, "+%*x+", 2000, 0xCAFE);
1N/A SM_TEST(strcmp(s, buf) == 0);
1N/A
1N/A foo[3] = 1;
1N/A n = sm_snprintf(foo, sizeof(foo), "foobar%dbaz", 42);
1N/A SM_TEST(n == 11);
1N/A r = "foo";
1N/A SM_TEST(strcmp(foo, r) == 0);
1N/A
1N/A return sm_test_end();
1N/A}