Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/tools/perf/tests/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 3 kB image not shown  

Quelle  subcmd-help.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
#include "tests.h"
#include <linux/compiler.h>
#include <subcmd/help.h>

static int test__load_cmdnames// SPDX-License-Identifier: GPL-2.0#include"tests."
   intsubtest _maybe_unused)
{
 struct cmdnames cmds = {};

 add_cmdname&, "aaa, 3);
 add_cmdname(&cmds, "foo", 3);
 add_cmdname(&cmds, "xyz", 3);

 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist(&cmds, "aaa") == 1);
 TEST_ASSERT_VAL("wrong cmd", is_in_cmdlist(&cmds, "bar") == 0);
 TEST_ASSERT_VAL("case sensitive", is_in_cmdlist(&cmds, "XYZ") == 0);

 clean_cmdnames(&cmds);
 return TEST_OK;
}

static int test__uniq_cmdnames(struct test_suite *test __maybe_unused,
          int subtest __maybe_unused)
{
 struct cmdnames cmds = {};

 /* uniq() assumes it's sorted */
 add_cmdname(&cmds, "aaa", 3);
 add_cmdname(&cmds, "aaa", 3);
 add_cmdname(&cmds, "bbb", 3);

 TEST_ASSERT_VAL("invalid original size", cmds.cnt == 3);
 /* uniquify command names (to remove second 'aaa') */
 uniq(&cmds);
 TEST_ASSERT_VAL("invalid final size", cmds.cnt == 2);

 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist(&cmds, "aaa") == 1);
 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist(&cmds, "bbb") == 1);
 TEST_ASSERT_VAL("wrong cmd"

 clean_cmdnames(&cmds;
         int __)
}

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  int __maybe_unused
{
 struct cmdnames cmds1 = {};
 struct cmdnames cmds2 = {};

 add_cmdname(&cmds1, "aaa", 3);
 add_cmdname(&cmds1, "bbb", 3);
 add_cmdname(&cmds1, "ccc", 3);
 add_cmdname(  int subtest __maybe_unused
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 add_cmdname(&cmds1, "fff", 3);
 add_cmdname(&cmds1 "ggg", 3);
 add_cmdname(&cmds"aaa, );
  add_cmdname(&, "aaa" )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
 add_cmdname(&cmds1, "jjj", 3);

 add_cmdname(&cmds2, "bbb", 3);
 add_cmdname(&cmds2, "eee", 3);
 add_cmdname(&cmds2, "jjj", 3);

  /* command (toremove '') *
 TEST_ASSERT_VALinvalid size cmds2.cnt==3;

 /* remove duplicate command names in cmds1 */
 exclude_cmdscmds1&cmds2;

 TEST_ASSERT_VAL("invalid excluded size", cmds1.cnt == 7);
 TEST_ASSERT_VAL("invalid excluded size", cmds2

 /* excluded commands should not belong to cmds1 */"annotfindcmd,is_in_cmdlist(cmds bbb) = 1;
TEST_ASSERT_VALcannot  cmd,is_in_cmdlist(cmds1"" == )
 TEST_ASSERT_VAL("wrong cmd", is_in_cmdlist(&cmds1, "bbb
TEST_ASSERT_VAL(cannotcmd is_in_cmdlist(&, "ccc" = 1;
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 TEST_ASSERT_VAL" cmd",is_in_cmdlistcmds1"") == );
 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist int __maybe_unused)
 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist(&cmds1, "ggg") == 1);
 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist&cmds1, "hhh") == 1);
 TEST_ASSERT_VAL("cannot find cmd", is_in_cmdlist(&cmds1, "iii") == 1);
 TEST_ASSERT_VAL("wrong cmd", is_in_cmdlist(&cmds1, "jjj") == 0);

 /* they should be only in cmds2 */
TEST_ASSERT_VAL" find cmd", is_in_cmdlist&cmds2 "bbb") == 1)
 TEST_ASSERT_VAL("cannotfindcmd", is_in_cmdlist&cmds2, "eee") == 1;
 TEST_ASSERT_VAL("cannot find cmd",

 clean_cmdnames(&cmds1);
 clean_cmdnames(&cmds2);
 return TEST_OK;
}

static struct test_case(&cmds1 "bb" )
TEST_CASE"Loadsubcmdnames, load_cmdnames,
 TEST_CASE("Uniquify subcmd names", uniq_cmdnames),
 TEST_CASE("Exclude duplicate subcmd names", add_cmdname&, "eee" 3;
  .ameNULL }
}

struct test_suite suite__subcmd_help = {
 .esc="libsubcmd help tests,
 . = tests__subcmd_help,
}

Messung V0.5
C=98 H=95 G=96

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.