Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/src/shared/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  string-sample.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it } from "vitest";
import { summarizeStringEntries } from "./string-sample.js";

describe("summarizeStringEntries", () => {
  it("returns emptyText for empty lists", () => {
    expect(summarizeStringEntries({ entries: [], emptyText: "any" })).toBe("any");
    expect(summarizeStringEntries({ entries: null })).toBe("");
  });

  it("joins short lists without a suffix", () => {
    expect(summarizeStringEntries({ entries: ["a", "b"], limit: 4 })).toBe("a, b");
  });

  it("adds a remainder suffix when truncating", () => {
    expect(
      summarizeStringEntries({
        entries: ["a", "b", "c", "d", "e"],
        limit: 4,
      }),
    ).toBe("a, b, c, d (+1)");
  });

  it("uses a floored limit and clamps non-positive values to one entry", () => {
    expect(
      summarizeStringEntries({
        entries: ["a", "b", "c"],
        limit: 2.8,
      }),
    ).toBe("a, b (+1)");
    expect(
      summarizeStringEntries({
        entries: ["a", "b", "c"],
        limit: 0,
      }),
    ).toBe("a (+2)");
  });

  it("uses the default limit when none is provided", () => {
    expect(
      summarizeStringEntries({
        entries: ["a", "b", "c", "d", "e", "f", "g"],
      }),
    ).toBe("a, b, c, d, e, f (+1)");
  });

  it("does not add a suffix when the limit exactly matches the entry count", () => {
    expect(
      summarizeStringEntries({
        entries: ["a", "b", "c"],
        limit: 3,
        emptyText: "ignored",
      }),
    ).toBe("a, b, c");
  });
});

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© 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.