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

Quelle  string-sample.test.ts

  Sprache: JAVA
 

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");
  });
});

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.