Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

pgutil.js 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. const assert = require('assert');
  2. const pgu = require('../lib/pgutil');
  3. describe('escape', () => {
  4. it('should pass through an empty string', () => {
  5. assert.equal(pgu.escapePGText('').length, 0);
  6. })
  7. it('should pass through an empty buffer', () => {
  8. assert.equal(pgu.escapePGText('').length, 0);
  9. })
  10. it('should pass through text', () => {
  11. assert.equal(pgu.escapePGText('woozle').toString(), 'woozle');
  12. })
  13. it('should escape a backslash', () => {
  14. assert.equal(pgu.escapePGText('\\').toString(), '\\\\');
  15. })
  16. it('should escape a newline', () => {
  17. assert.equal(pgu.escapePGText('\n').toString(), '\\n');
  18. })
  19. it('should escape a carriage return', () => {
  20. assert.equal(pgu.escapePGText('\r').toString(), '\\r');
  21. })
  22. it('should escape a tab', () => {
  23. assert.equal(pgu.escapePGText('\t').toString(), '\\t');
  24. })
  25. it('should escape a tab in text', () => {
  26. assert.equal(pgu.escapePGText('foo\tbar').toString(), 'foo\\tbar');
  27. })
  28. it('should escape stuff in text', () => {
  29. assert.equal(pgu.escapePGText('foo\tbar\r\n\\foobat').toString(), 'foo\\tbar\\r\\n\\\\foobat');
  30. })
  31. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...