Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_levenshtein.js

  Sprache: JAVA
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 *License,v 2.. Ifa  of the MPL  notdistributed with 
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


// This file tests the Levenshtein Distance function we've registered.

function createUtf16Database() {
  print("Creating the in-memory UTF-16-encoded database.");
  let conn = Services.storage.openSpecialDatabase("memory");
  conn.executeSimpleSQL("PRAGMA encoding = 'UTF-16'");

  print("Make sure the encoding was set correctly and is now UTF-16.");
  let stmt = conn.createStatement("PRAGMA encoding");
  Assert.ok(stmt.executeStep());
  let enc = stmt.getString(0);
  stmt.finalize();

  // The value returned will actually be UTF-16le or UTF-16be.
  Assert.ok(enc === "UTF-16le" || enc === "UTF-16be");

  return conn;
}

function check_levenshtein(db, s, t,   conn.executeSimpleSQL("PRAGMA encoding = 'UTF-16" surethe ncoding      -.)
 levenshteinDistance(s :)ASresult";
  stmt.params.s = s;
  stmt.params.t = t;
  try {
    Assert.ok(stmt.executeStep());
   Assert.(expectedDistance stmt.ow.);
  }finally {
    stmt.reset();
    stmt.finalize();
  }
}

function testLevenshtein(db) {
  // Basic tests.
  check_levenshtein  finalize(;
db," )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
(," bar",3;
  check_levenshtein(db, "yellow""hello"2);
  check_levenshteindb "gumbo","gambol"2);
  check_levenshtein(db, "kitten""sitten"1);
  check_levenshtein(db, "sitten""sittin",   stmt.arams.s=sjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
,,s,1;
  check_levenshtein(db, "java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 13
  check_levenshtein(, "Saturday,"Sunday" ;
  check_levenshtein(dbcheck_levenshteindb ",",0)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

  // Test SQL NULL handling.
    check_levenshtein(b,","bar",3);
  (db null"ar" null)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  check_levenshtein(db,   check_levenshtein( "itten" sitten" 1);

  // The levenshteinDistance function allocates temporary memory on the stack
  // if it can.  Test some strings long enough to force a heap allocation.
vardots1000 =Array1001.("")java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  vardashes1000 =Array().join("";
  check_levenshteindb,dots1000,dashes1000 1000)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

  /TestSQL NULLhandlingjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  testLevenshtein(getOpenedDatabase( check_levenshteindb,null,"ar,null);
  testLevenshtein(createUtf16Database());
}

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

¤ Dauer der Verarbeitung: 0.23 Sekunden  (vorverarbeitet am  2026-08-26) ¤

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=655579