Declare the alphabet a GSM message is actually written in (#100)

* Regression tests for the alphabet a GSM message declares

* Declare the alphabet a GSM message is actually written in

* Reflow the composing-by-hand paragraph

* Drop the ASCII alias SMPP's flat table shares with the option's own

* Bound the receipt test's wait and tighten the notes around it
This commit is contained in:
2026-09-09 21:30:55 +02:00
committed by GitHub
parent 989eb01763
commit ca1a7473ed
15 changed files with 275 additions and 33 deletions
+9 -1
View File
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import test, { describe } from 'node:test';
import { detect, encodingByDataCoding, encodings, unencodable } from '../src/defs/encodings.ts';
import { dataCodingByEncoding, detect, encodingByDataCoding, encodings, isEncodingName, unencodable } from '../src/defs/encodings.ts';
describe('ASCII (GSM 03.38)', () => {
const samples: [string, number[]][] = [
@@ -188,6 +188,14 @@ describe('encodingByDataCoding()', () => {
}
});
test('reads every coding dataCodingByEncoding writes back as the alphabet that wrote it', () => {
for (const name of Object.keys(dataCodingByEncoding)) {
if (!isEncodingName(name)) return assert.fail(`${name} names no alphabet`);
assert.equal(encodingByDataCoding(dataCodingByEncoding[name]), name);
}
});
test('falls back to ASCII for alphabets it has no codec for', () => {
assert.equal(encodingByDataCoding(0x05), 'ASCII');
assert.equal(encodingByDataCoding(0x0E), 'ASCII');