Best Python code snippet using grail_python
index.test.ts
Source:index.test.ts
2import { convert as bahtLatest } from 'baht';3const { ThaiBaht: thaiBahtText } = require('thai-baht-text-ts');4describe('convert', () => {5 it('works', () => {6 expect(convert(0)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');7 expect(convert(1)).toBe('หà¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');8 expect(convert(2)).toBe('สà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');9 expect(convert(5)).toBe('หà¹à¸²à¸à¸²à¸à¸à¹à¸§à¸');10 expect(convert(9)).toBe('à¹à¸à¹à¸²à¸à¸²à¸à¸à¹à¸§à¸');11 expect(convert(10)).toBe('สิà¸à¸à¸²à¸à¸à¹à¸§à¸');12 expect(convert(20)).toBe('ยีà¹à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');13 expect(convert(30)).toBe('สามสิà¸à¸à¸²à¸à¸à¹à¸§à¸');14 expect(convert(45)).toBe('สีà¹à¸ªà¸´à¸à¸«à¹à¸²à¸à¸²à¸à¸à¹à¸§à¸');15 expect(convert(100)).toBe('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸à¸²à¸à¸à¹à¸§à¸');16 expect(convert(122)).toBe('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');17 expect(convert(190)).toBe('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');18 expect(convert(290)).toBe('สà¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');19 expect(convert(1000)).toBe('หà¸à¸¶à¹à¸à¸à¸±à¸à¸à¸²à¸à¸à¹à¸§à¸');20 expect(convert(10000)).toBe('หà¸à¸¶à¹à¸à¸«à¸¡à¸·à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');21 expect(convert(100000)).toBe('หà¸à¸¶à¹à¸à¹à¸ªà¸à¸à¸²à¸à¸à¹à¸§à¸');22 expect(convert(100001)).toBe('หà¸à¸¶à¹à¸à¹à¸ªà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');23 expect(convert(100005)).toBe('หà¸à¸¶à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸à¸²à¸à¸à¹à¸§à¸');24 expect(convert(100021)).toBe('หà¸à¸¶à¹à¸à¹à¸ªà¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');25 expect(convert(1000000)).toBe('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');26 expect(convert(1002000)).toBe('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸ªà¸à¸à¸à¸±à¸à¸à¸²à¸à¸à¹à¸§à¸');27 expect(convert(10000000)).toBe('สิà¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');28 expect(convert(10002000)).toBe('สิà¸à¸¥à¹à¸²à¸à¸ªà¸à¸à¸à¸±à¸à¸à¸²à¸à¸à¹à¸§à¸');29 });30 it('returns false for bad inputs', () => {31 expect(convert('hello')).toBe(false);32 expect(convert((false as unknown) as number)).toBe(false);33 expect(convert((true as unknown) as number)).toBe(false);34 expect(convert(({} as unknown) as number)).toBe(false);35 expect(convert(([] as unknown) as number)).toBe(false);36 expect(convert(('155233.4b6' as unknown) as number)).toBe(false);37 expect(convert(('155233.476a85' as unknown) as number)).toBe(false);38 });39 it('should be a function', () => {40 expect(convert).toEqual(expect.any(Function));41 });42 it('convert to 0', () => {43 expect(convert(0)).toEqual('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');44 expect(convert(0.0)).toEqual('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');45 expect(convert(0.0001)).toEqual('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');46 expect(convert(0.001)).toEqual('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');47 expect(convert(0.009)).toEqual('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');48 });49 it('should convert to Satang', () => {50 expect(convert(0.01)).toEqual('หà¸à¸¶à¹à¸à¸ªà¸à¸²à¸à¸à¹');51 expect(convert(0.1)).toEqual('สิà¸à¸ªà¸à¸²à¸à¸à¹');52 expect(convert(0.1)).toEqual('สิà¸à¸ªà¸à¸²à¸à¸à¹');53 expect(convert(0.11)).toEqual('สิà¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹');54 expect(convert(0.12)).toEqual('สิà¸à¸ªà¸à¸à¸ªà¸à¸²à¸à¸à¹');55 expect(convert(0.123)).toEqual('สิà¸à¸ªà¸à¸à¸ªà¸à¸²à¸à¸à¹');56 expect(convert(0.2)).toEqual('ยีà¹à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');57 expect(convert(0.2)).toEqual('ยีà¹à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');58 expect(convert(0.21)).toEqual('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹');59 expect(convert(0.25)).toEqual('ยีà¹à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');60 expect(convert(0.255)).toEqual('ยีà¹à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');61 expect(convert(0.5)).toEqual('หà¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');62 expect(convert(0.75)).toEqual('à¹à¸à¹à¸à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');63 expect(convert(0.99)).toEqual('à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹');64 expect(convert(0.999)).toEqual('à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹');65 });66 it('should convert to Baht', () => {67 expect(convert(1)).toEqual('หà¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');68 expect(convert(10)).toEqual('สิà¸à¸à¸²à¸à¸à¹à¸§à¸');69 expect(convert(11)).toEqual('สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');70 expect(convert(12)).toEqual('สิà¸à¸ªà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');71 expect(convert(20)).toEqual('ยีà¹à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');72 expect(convert(21)).toEqual('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');73 expect(convert(22)).toEqual('ยีà¹à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');74 expect(convert(100)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸à¸²à¸à¸à¹à¸§à¸');75 expect(convert(101)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');76 expect(convert(111)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');77 expect(convert(121)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');78 });79 it('should convert to negative baht', () => {80 expect(convert(-1)).toEqual('ลà¸à¸«à¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');81 expect(convert(-10)).toEqual('ลà¸à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');82 expect(convert(-11)).toEqual('ลà¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');83 expect(convert(-12)).toEqual('ลà¸à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');84 expect(convert(-20)).toEqual('ลà¸à¸¢à¸µà¹à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');85 expect(convert(-21)).toEqual('ลà¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');86 expect(convert(-22)).toEqual('ลà¸à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸à¹à¸§à¸');87 expect(convert(-100)).toEqual('ลà¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸à¸²à¸à¸à¹à¸§à¸');88 expect(convert(-101)).toEqual('ลà¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');89 expect(convert(-111)).toEqual('ลà¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');90 expect(convert(-121)).toEqual('ลà¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');91 });92 it('should convert 1-99 satangs correctly compared to baht', () => {93 const bahtArray = [];94 const satangArray = [];95 for (let i = 1; i < 100; i++) {96 bahtArray.push((convert(i) as string).replace('à¸à¸²à¸à¸à¹à¸§à¸', ''));97 satangArray.push(98 (convert(+`0.${i.toString().padStart(2, '0')}`) as string).replace(99 'สà¸à¸²à¸à¸à¹',100 ''101 )102 );103 }104 expect(bahtArray).toEqual(satangArray);105 });106 it('should convert big number to Baht', () => {107 expect(convert(1000000)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');108 expect(convert(1000001)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');109 expect(convert(11000001)).toEqual('สิà¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');110 expect(convert(11000000)).toEqual('สิà¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');111 expect(convert(21000000)).toEqual('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');112 expect(convert(21000010)).toEqual('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');113 expect(convert(21000011)).toEqual('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');114 expect(convert(121000011)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');115 });116 it('should convert multiple million round to Baht', () => {117 expect(convert(1000000000000000000)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸¥à¹à¸²à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');118 expect(convert(1000000000001)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');119 expect(convert(1000000000000)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');120 expect(convert(1001000000001)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');121 expect(convert(1001000001001)).toEqual(122 'หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'123 );124 expect(convert(1001000000000)).toEqual('หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');125 expect(convert(1000000000)).toEqual('หà¸à¸¶à¹à¸à¸à¸±à¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');126 expect(convert(10000000)).toEqual('สิà¸à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');127 expect(convert(100000000)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¥à¹à¸²à¸à¸à¸²à¸à¸à¹à¸§à¸');128 // Safe integer129 expect(convert(9007199254740991)).toEqual(130 'à¹à¸à¹à¸²à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¹à¸²à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸ªà¸µà¹à¸«à¸¡à¸·à¹à¸à¹à¸à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'131 );132 });133 it('should convert complex number to Baht', () => {134 expect(convert(6321298)).toEqual(135 'หà¸à¸¥à¹à¸²à¸à¸ªà¸²à¸¡à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸à¸²à¸à¸à¹à¸§à¸'136 );137 expect(convert(10034567)).toEqual(138 'สิà¸à¸¥à¹à¸²à¸à¸ªà¸²à¸¡à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'139 );140 expect(convert(20034567)).toEqual(141 'ยีà¹à¸ªà¸´à¸à¸¥à¹à¸²à¸à¸ªà¸²à¸¡à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'142 );143 expect(convert(30034567.0)).toEqual(144 'สามสิà¸à¸¥à¹à¸²à¸à¸ªà¸²à¸¡à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'145 );146 expect(convert(1534325986.4336942)).toEqual(147 'หà¸à¸¶à¹à¸à¸à¸±à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸ªà¸²à¸¡à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸à¸±à¸à¹à¸à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¸«à¸à¸à¸²à¸à¸ªà¸µà¹à¸ªà¸´à¸à¸ªà¸²à¸¡à¸ªà¸à¸²à¸à¸à¹'148 );149 });150 it('should convert number to Baht with Satang', () => {151 expect(convert(11.25)).toEqual('สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');152 expect(convert(100.5)).toEqual('หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');153 expect(convert(567.01)).toEqual('หà¹à¸²à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸«à¸à¸¶à¹à¸à¸ªà¸à¸²à¸à¸à¹');154 expect(convert(123456789.999)).toEqual(155 'หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸²à¸¡à¸¥à¹à¸²à¸à¸ªà¸µà¹à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸à¸²à¸à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'156 );157 });158 it('should convert number in string format', () => {159 expect(convert(('1234' as unknown) as number)).toBe(160 'หà¸à¸¶à¹à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸µà¹à¸à¸²à¸à¸à¹à¸§à¸'161 );162 expect(convert(('-1' as unknown) as number)).toBe('ลà¸à¸«à¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');163 expect(convert(('-30' as unknown) as number)).toBe('ลà¸à¸ªà¸²à¸¡à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');164 expect(convert(('123456789.999' as unknown) as number)).toEqual(165 'หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸²à¸¡à¸¥à¹à¸²à¸à¸ªà¸µà¹à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸à¸²à¸à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'166 );167 expect(convert(('4123001998830750501' as unknown) as number)).toBe(168 'สีà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'169 );170 expect(convert(('-4123001998830750501' as unknown) as number)).toBe(171 'ลà¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'172 );173 expect(convert(('-4123001998830750501.21' as unknown) as number)).toBe(174 'ลà¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'175 );176 expect(convert(('-1654321.21' as unknown) as number)).toBe(177 'ลà¸à¸«à¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸ªà¸²à¸¡à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'178 );179 expect(convert(('152555.4' as unknown) as number)).toBe(180 'หà¸à¸¶à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸à¸à¸à¸±à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¸«à¹à¸²à¸ªà¸´à¸à¸«à¹à¸²à¸à¸²à¸à¸ªà¸µà¹à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹'181 );182 expect((convert('535.') as unknown) as number).toBe(183 'หà¹à¸²à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸«à¹à¸²à¸à¸²à¸à¸à¹à¸§à¸'184 );185 });186 it('should convert with leading zero before the decimal point in string format.', () => {187 expect(convert(('0' as unknown) as number)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');188 expect(convert(('-0' as unknown) as number)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');189 expect(convert(('09.05' as unknown) as number)).toBe('à¹à¸à¹à¸²à¸à¸²à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');190 expect(convert(('11' as unknown) as number)).toBe('สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');191 expect(convert(('01234' as unknown) as number)).toBe(192 'หà¸à¸¶à¹à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸µà¹à¸à¸²à¸à¸à¹à¸§à¸'193 );194 expect(convert(('-01' as unknown) as number)).toBe('ลà¸à¸«à¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');195 expect(convert(('-011' as unknown) as number)).toBe('ลà¸à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');196 expect(convert(('-021' as unknown) as number)).toBe('ลà¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');197 expect(convert(('-030' as unknown) as number)).toBe('ลà¸à¸ªà¸²à¸¡à¸ªà¸´à¸à¸à¸²à¸à¸à¹à¸§à¸');198 expect(convert(('0123456789.999' as unknown) as number)).toEqual(199 'หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸²à¸¡à¸¥à¹à¸²à¸à¸ªà¸µà¹à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸à¸²à¸à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'200 );201 expect(convert(('04123001998830750501' as unknown) as number)).toBe(202 'สีà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'203 );204 expect(convert(('-04123001998830750501' as unknown) as number)).toBe(205 'ลà¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'206 );207 expect(convert(('-04123001998830750501.21' as unknown) as number)).toBe(208 'ลà¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'209 );210 expect(convert(('-01654321.21' as unknown) as number)).toBe(211 'ลà¸à¸«à¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸ªà¸²à¸¡à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'212 );213 });214 it('should convert looping string numbers correctly', () => {215 for (let i = 100; i >= 0; i--) {216 const loopingNumber = Array(i)217 .fill('654321028761')218 .join('');219 const loopingText = Array(i)220 .fill(221 'ลà¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸ªà¸²à¸¡à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¹à¸à¹à¸'222 )223 .join('');224 expect(225 convert((`-1${loopingNumber}.21${555555}` as unknown) as number)226 ).toBe(`ลà¸à¸«à¸à¸¶à¹à¸${loopingText}à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹`);227 }228 });229 it('IEEE 754 Case String', () => {230 expect(convert(('283798.29' as unknown) as number)).toBe(231 'สà¸à¸à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'232 );233 expect(convert(('486293.57' as unknown) as number)).toBe(234 'สีà¹à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸ªà¸²à¸¡à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'235 );236 expect(convert(('552164.58' as unknown) as number)).toBe(237 'หà¹à¸²à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸à¸à¸à¸±à¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¸ªà¸µà¹à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸ªà¸à¸²à¸à¸à¹'238 );239 });240 it('IEEE 754 Case Small Number (<1000)', () => {241 expect(convert(0.29)).toBe('ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹');242 expect(convert(553.57)).toBe('หà¹à¸²à¸£à¹à¸à¸¢à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸²à¸¡à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹');243 expect(convert(790.58)).toBe('à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸ªà¸à¸²à¸à¸à¹');244 });245 it('IEEE 754 Case Big Number (>100000)', () => {246 expect(convert(283798.29)).toBe(247 'สà¸à¸à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'248 );249 expect(convert(486293.57)).toBe(250 'สีà¹à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸ªà¸²à¸¡à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'251 );252 expect(convert(874552164.58)).toBe(253 'à¹à¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸ªà¸´à¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¹à¸²à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸à¸à¸à¸±à¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¸ªà¸µà¹à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸ªà¸à¸²à¸à¸à¹'254 );255 expect(convert(5143289600432.29)).toBe(256 'หà¹à¸²à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸µà¹à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸¥à¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸ªà¸µà¹à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'257 );258 });259 it('should convert spaces as 0', () => {260 expect(convert(('' as unknown) as number)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');261 expect(convert((' ' as unknown) as number)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');262 expect(convert((' ' as unknown) as number)).toBe('ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸');263 });264 it('should convert number surrounding with spaces or zeros correctly', () => {265 const generateSpaceTest = (266 input: string,267 output: string,268 negativeOutput = ''269 ) => {270 const neg_output = negativeOutput || 'ลà¸' + output;271 const int_tests = [272 [` ${input}`, output],273 [`${input} `, output],274 [` ${input} `, output],275 [` 0${input}`, output],276 [`0${input} `, output],277 [` 0${input} `, output],278 [` 00${input}`, output],279 [`00${input} `, output],280 [` 00${input} `, output],281 [` -${input}`, neg_output],282 [`-${input} `, neg_output],283 [` -${input} `, neg_output],284 [` -0${input}`, neg_output],285 [`-0${input} `, neg_output],286 [` -0${input} `, neg_output],287 [` -00${input}`, neg_output],288 [`-00${input} `, neg_output],289 [` -00${input} `, neg_output],290 ];291 const float_tests = [292 [` ${input}0`, output],293 [`${input}0 `, output],294 [` ${input}0 `, output],295 [` ${input}00`, output],296 [`${input}00 `, output],297 [` ${input}00 `, output],298 [` 0${input}0`, output],299 [`0${input}0 `, output],300 [` 0${input}0 `, output],301 [` 0${input}00`, output],302 [`0${input}00 `, output],303 [` 0${input}00 `, output],304 [` 00${input}0`, output],305 [`00${input}0 `, output],306 [` 00${input}0 `, output],307 [` 00${input}00`, output],308 [`00${input}00 `, output],309 [` 00${input}00 `, output],310 [` -${input}0`, neg_output],311 [`-${input}0 `, neg_output],312 [` -${input}0 `, neg_output],313 [` -${input}00`, neg_output],314 [`-${input}00 `, neg_output],315 [` -${input}00 `, neg_output],316 [` -0${input}0`, neg_output],317 [`-0${input}0 `, neg_output],318 [` -0${input}0 `, neg_output],319 [` -0${input}00`, neg_output],320 [`-0${input}00 `, neg_output],321 [` -0${input}00 `, neg_output],322 [` -00${input}0`, neg_output],323 [`-00${input}0 `, neg_output],324 [` -00${input}0 `, neg_output],325 [` -00${input}00`, neg_output],326 [`-00${input}00 `, neg_output],327 [` -00${input}00 `, neg_output],328 ];329 const tests = input.includes('.')330 ? int_tests.concat(float_tests)331 : int_tests;332 tests.forEach(([input, expected]) => {333 expect(convert((input as unknown) as number)).toBe(expected);334 });335 };336 // Normal Test337 generateSpaceTest('0', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸'); // -0 is same as 0338 generateSpaceTest('0.0', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸'); // -0.0 is same as 0.0339 generateSpaceTest('0.5', 'หà¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');340 generateSpaceTest('0.00', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸', 'ศูà¸à¸¢à¹à¸à¸²à¸à¸à¹à¸§à¸'); // -0.00 is same as 0.00341 generateSpaceTest('0.50', 'หà¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');342 generateSpaceTest('0.55', 'หà¹à¸²à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');343 generateSpaceTest('1', 'หà¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');344 generateSpaceTest('1.0', 'หà¸à¸¶à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');345 generateSpaceTest('9.5', 'à¹à¸à¹à¸²à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');346 generateSpaceTest('9.00', 'à¹à¸à¹à¸²à¸à¸²à¸à¸à¹à¸§à¸');347 generateSpaceTest('9.50', 'à¹à¸à¹à¸²à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');348 generateSpaceTest('9.55', 'à¹à¸à¹à¸²à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸«à¹à¸²à¸ªà¸à¸²à¸à¸à¹');349 generateSpaceTest('11', 'สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');350 generateSpaceTest('11.0', 'สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');351 generateSpaceTest('11.5', 'สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');352 generateSpaceTest('11.00', 'สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸');353 generateSpaceTest('11.50', 'สิà¸à¹à¸à¹à¸à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸à¸²à¸à¸à¹');354 generateSpaceTest('12.34', 'สิà¸à¸ªà¸à¸à¸à¸²à¸à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸µà¹à¸ªà¸à¸²à¸à¸à¹');355 // From other tests356 generateSpaceTest(357 '123456789.999',358 'หà¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¸ªà¸²à¸¡à¸¥à¹à¸²à¸à¸ªà¸µà¹à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸à¸²à¸à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'359 );360 generateSpaceTest(361 '4123001998830750501',362 'สีà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸à¹à¸§à¸'363 );364 generateSpaceTest(365 '4123001998830750501.21',366 'สีà¹à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸²à¹à¸ªà¸à¹à¸à¹à¸²à¸«à¸¡à¸·à¹à¸à¹à¸à¸à¸à¸±à¸à¹à¸à¸à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸¥à¹à¸²à¸à¹à¸à¹à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸«à¹à¸²à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'367 );368 generateSpaceTest(369 '1654321.21',370 'หà¸à¸¶à¹à¸à¸¥à¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸µà¹à¸à¸±à¸à¸ªà¸²à¸¡à¸£à¹à¸à¸¢à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'371 );372 // IEEE Test373 generateSpaceTest('0.29', 'ยีà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹');374 generateSpaceTest('553.57', 'หà¹à¸²à¸£à¹à¸à¸¢à¸«à¹à¸²à¸ªà¸´à¸à¸ªà¸²à¸¡à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹');375 generateSpaceTest('790.58', 'à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸ªà¸à¸²à¸à¸à¹');376 generateSpaceTest(377 '283798.29',378 'สà¸à¸à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¹à¸à¹à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'379 );380 generateSpaceTest(381 '486293.57',382 'สีà¹à¹à¸ªà¸à¹à¸à¸à¸«à¸¡à¸·à¹à¸à¸«à¸à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸²à¸ªà¸´à¸à¸ªà¸²à¸¡à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¹à¸à¸ªà¸à¸²à¸à¸à¹'383 );384 generateSpaceTest(385 '874552164.58',386 'à¹à¸à¸à¸£à¹à¸à¸¢à¹à¸à¹à¸à¸ªà¸´à¸à¸ªà¸µà¹à¸¥à¹à¸²à¸à¸«à¹à¸²à¹à¸ªà¸à¸«à¹à¸²à¸«à¸¡à¸·à¹à¸à¸ªà¸à¸à¸à¸±à¸à¸«à¸à¸¶à¹à¸à¸£à¹à¸à¸¢à¸«à¸à¸ªà¸´à¸à¸ªà¸µà¹à¸à¸²à¸à¸«à¹à¸²à¸ªà¸´à¸à¹à¸à¸à¸ªà¸à¸²à¸à¸à¹'387 );388 generateSpaceTest(389 '5143289600432.29',390 'หà¹à¸²à¸¥à¹à¸²à¸à¸«à¸à¸¶à¹à¸à¹à¸ªà¸à¸ªà¸µà¹à¸«à¸¡à¸·à¹à¸à¸ªà¸²à¸¡à¸à¸±à¸à¸ªà¸à¸à¸£à¹à¸à¸¢à¹à¸à¸à¸ªà¸´à¸à¹à¸à¹à¸²à¸¥à¹à¸²à¸à¸«à¸à¹à¸ªà¸à¸ªà¸µà¹à¸£à¹à¸à¸¢à¸ªà¸²à¸¡à¸ªà¸´à¸à¸ªà¸à¸à¸à¸²à¸à¸¢à¸µà¹à¸ªà¸´à¸à¹à¸à¹à¸²à¸ªà¸à¸²à¸à¸à¹'391 );392 });393 // it('equals to value from other library (STRESS TEST)', () => {394 // for (let i = 1; i < 20000000; i += 1) {395 // expect(convert(i)).toEqual(bahtLatest(i));396 // expect(convert(i)).toEqual(thaiBahtText(i));397 // }398 // });...
state_current.py
Source:state_current.py
...220 if k == 'EdgeFlag':221 print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)222 dirtyVar = 'cb->edgeFlag'223 elif k == 'Normal':224 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)225 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'226 elif k == 'TexCoord':227 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)228 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'229 elif k == 'Color':230 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)231 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'232 elif k == 'Index':233 print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)234 dirtyVar = 'cb->colorIndex'235 elif k == 'SecondaryColor':236 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)237 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'238 elif k == 'FogCoord':239 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)240 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'241 elif k == 'VertexAttrib':242 print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)243 dirtyVar = 'cb->vertexAttrib[i]'244 else:245 assert 0 # should never get here246 print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)247# if current_fns[k].has_key( 'array' ):248# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)249# else:250# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name)251 print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent252 print '%s\t}' % indent253 if current_fns[k].has_key( 'array' ):254 print '%s\t%s->ptr[i] = v;' % (indent, name )255 else:256 print '%s\t%s->ptr = v;' % (indent, name )257 if current_fns[k].has_key( 'array' ):258 print '\t}'259print '}'260print '''261void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers *current)262{263 const unsigned char *v;264 convert_func convert=NULL;265 CRCurrentState *c = &(g->current);266 CRStateBits *sb = GetCurrentBits();267 CRCurrentBits *cb = &(sb->current);268 static const GLfloat vertexAttrib_default[4] = {0.0f, 0.0f, 0.0f, 1.0f};269 GLvertexattrib_p *vertexAttrib = &(current->c.vertexAttrib);270 unsigned int i;271 CRbitvalue nbitID[CR_MAX_BITARRAY];272 /* silence warnings */273 (void) __convert_b1;274 (void) __convert_b2;275 (void) __convert_b3;276 (void) __convert_b4;277 (void) __convert_ui1;278 (void) __convert_ui2;279 (void) __convert_ui3;280 (void) __convert_ui4;281 (void) __convert_l1;282 (void) __convert_l2;283 (void) __convert_l3;284 (void) __convert_l4;285 (void) __convert_us1;286 (void) __convert_us2;287 (void) __convert_us3;288 (void) __convert_us4;289 (void) __convert_ub1;290 (void) __convert_ub2;291 (void) __convert_ub3;292 (void) __convert_ub4;293 (void) __convert_rescale_s1;294 (void) __convert_rescale_s2;295 (void) __convert_rescale_b1;296 (void) __convert_rescale_b2;297 (void) __convert_rescale_ui1;298 (void) __convert_rescale_ui2;299 (void) __convert_rescale_i1;300 (void) __convert_rescale_i2;301 (void) __convert_rescale_us1;302 (void) __convert_rescale_us2;303 (void) __convert_rescale_ub1;304 (void) __convert_rescale_ub2;305 (void) __convert_Ni1;306 (void) __convert_Ni2;307 (void) __convert_Ni3;308 (void) __convert_Ni4;309 (void) __convert_Nb1;310 (void) __convert_Nb2;311 (void) __convert_Nb3;312 (void) __convert_Nb4;313 (void) __convert_Nus1;314 (void) __convert_Nus2;315 (void) __convert_Nus3;316 (void) __convert_Nus4;317 (void) __convert_Nui1;318 (void) __convert_Nui2;319 (void) __convert_Nui3;320 (void) __convert_Nui4;321 (void) __convert_Ns1;322 (void) __convert_Ns2;323 (void) __convert_Ns3;324 (void) __convert_Ns4;325 (void) __convert_Nub1;326 (void) __convert_Nub2;327 (void) __convert_Nub3;328 (void) __convert_Nub4;329'''330for k in current_fns_new.keys():331 print '\t/* %s */' % k332 print '\tif (current->changed%s)' % k333 print '\t{'334 print '\t\tv=NULL;'335 name = '%s%s' % (k[:1].lower(),k[1:])336 indent = ""337 if current_fns_new[k].has_key( 'array' ):338 print '\t\tfor (i = 0 ; i < %s ; i++)' % current_fns_new[k]['array']339 print '\t\t{'340 indent += "\t\t"341 print '\t\tif (!(current->changed%s & (1 << i))) continue;' % k342 for type in current_fns_new[k]['types']:343 if type[0:1] == "N":344 normalized = 1345 type2 = type[1:]346 else:347 normalized = 0348 type2 = type349 for size in current_fns_new[k]['sizes']:350 ptr = '%s->%s%d' % (name, type, size )351 if current_fns_new[k].has_key( 'array' ):352 ptr += "[i]"353 print '#ifdef DEBUG_misha'354 print '%s\tif (%s)' % (indent, ptr)355 print '%s\t{' % (indent)356 print '%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr)357 print '%s\t\t--pTst;' % (indent)358 print '%s\t\tAssert((*pTst) == i);' % (indent)359 print '%s\t}' % (indent)360 print '#endif'361 print '%s\tif (v < %s)' % (indent, ptr)362 print '%s\t{' % indent363 print '%s\t\tv = %s;' % (indent, ptr)364 if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':365 print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)366 else:367 print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)368 print '%s\t}' % indent369 print ''370 print '%s\tif (v != NULL) {' % indent371 if current_fns_new[k].has_key( 'array' ):372 if k == 'TexCoord':373 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)374 else:375 print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)376 else:377 if k == 'Normal':378 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)379 elif k == 'FogCoord':380 print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] = %s_default;' % (indent,name)381 elif k == 'Color':382 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)383 elif k == 'SecondaryColor':384 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], %s_default);' % (indent,name)385 elif k == 'TexCoord':386 print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)387 elif k == 'Index':388 print '%s\t\tc->colorIndex = %s_default;' % (indent,name)389 elif k == 'EdgeFlag':390 print '%s\t\tc->edgeFlag = %s_default;' % (indent,name)391 else:392 print '%s\t\tc->%s = %s_default;' % (indent,name,name)393 if k == 'EdgeFlag':394 print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)395 dirtyVar = 'cb->edgeFlag'396 elif k == 'Normal':397 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)398 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'399 elif k == 'TexCoord':400 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)401 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'402 elif k == 'Color':403 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)404 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'405 elif k == 'Index':406 print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)407 dirtyVar = 'cb->colorIndex'408 elif k == 'SecondaryColor':409 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)410 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'411 elif k == 'FogCoord':412 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)413 dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'414 elif k == 'VertexAttrib':415 print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)416 dirtyVar = 'cb->vertexAttrib[i]'417 else:418 assert 0 # should never get here419 print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)420# if current_fns_new[k].has_key( 'array' ):421# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name)422# else:423# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name)424 print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent425 print '%s\t}' % indent426 if current_fns_new[k].has_key( 'array' ):427 print '%s\t%s->ptr[i] = v;' % (indent, name )428 else:429 print '%s\t%s->ptr = v;' % (indent, name )...
test_internals.py
Source:test_internals.py
...119 r = s.convert_objects(convert_numeric=True)120 e = Series([False, True, False, False], dtype=bool)121 tm.assert_series_equal(r, e)122 # GH 10265123 def test_convert(self):124 # Tests: All to nans, coerce, true125 # Test coercion returns correct type126 s = Series(['a', 'b', 'c'])127 results = s._convert(datetime=True, coerce=True)128 expected = Series([lib.NaT] * 3)129 assert_series_equal(results, expected)130 results = s._convert(numeric=True, coerce=True)131 expected = Series([np.nan] * 3)132 assert_series_equal(results, expected)133 expected = Series([lib.NaT] * 3, dtype=np.dtype('m8[ns]'))134 results = s._convert(timedelta=True, coerce=True)135 assert_series_equal(results, expected)136 dt = datetime(2001, 1, 1, 0, 0)137 td = dt - datetime(2000, 1, 1, 0, 0)138 # Test coercion with mixed types139 s = Series(['a', '3.1415', dt, td])140 results = s._convert(datetime=True, coerce=True)141 expected = Series([lib.NaT, lib.NaT, dt, lib.NaT])142 assert_series_equal(results, expected)143 results = s._convert(numeric=True, coerce=True)144 expected = Series([nan, 3.1415, nan, nan])145 assert_series_equal(results, expected)146 results = s._convert(timedelta=True, coerce=True)147 expected = Series([lib.NaT, lib.NaT, lib.NaT, td],148 dtype=np.dtype('m8[ns]'))149 assert_series_equal(results, expected)150 # Test standard conversion returns original151 results = s._convert(datetime=True)152 assert_series_equal(results, s)153 results = s._convert(numeric=True)154 expected = Series([nan, 3.1415, nan, nan])155 assert_series_equal(results, expected)156 results = s._convert(timedelta=True)157 assert_series_equal(results, s)158 # test pass-through and non-conversion when other types selected159 s = Series(['1.0', '2.0', '3.0'])160 results = s._convert(datetime=True, numeric=True, timedelta=True)161 expected = Series([1.0, 2.0, 3.0])162 assert_series_equal(results, expected)163 results = s._convert(True, False, True)164 assert_series_equal(results, s)165 s = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 1, 0, 0)],166 dtype='O')167 results = s._convert(datetime=True, numeric=True, timedelta=True)168 expected = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 1, 0,169 0)])170 assert_series_equal(results, expected)171 results = s._convert(datetime=False, numeric=True, timedelta=True)172 assert_series_equal(results, s)173 td = datetime(2001, 1, 1, 0, 0) - datetime(2000, 1, 1, 0, 0)174 s = Series([td, td], dtype='O')175 results = s._convert(datetime=True, numeric=True, timedelta=True)176 expected = Series([td, td])177 assert_series_equal(results, expected)178 results = s._convert(True, True, False)179 assert_series_equal(results, s)180 s = Series([1., 2, 3], index=['a', 'b', 'c'])181 result = s._convert(numeric=True)182 assert_series_equal(result, s)183 # force numeric conversion184 r = s.copy().astype('O')185 r['a'] = '1'186 result = r._convert(numeric=True)187 assert_series_equal(result, s)188 r = s.copy().astype('O')189 r['a'] = '1.'190 result = r._convert(numeric=True)191 assert_series_equal(result, s)192 r = s.copy().astype('O')193 r['a'] = 'garbled'194 result = r._convert(numeric=True)195 expected = s.copy()196 expected['a'] = nan197 assert_series_equal(result, expected)198 # GH 4119, not converting a mixed type (e.g.floats and object)199 s = Series([1, 'na', 3, 4])200 result = s._convert(datetime=True, numeric=True)201 expected = Series([1, nan, 3, 4])202 assert_series_equal(result, expected)203 s = Series([1, '', 3, 4])204 result = s._convert(datetime=True, numeric=True)205 assert_series_equal(result, expected)206 # dates207 s = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 2, 0, 0),208 datetime(2001, 1, 3, 0, 0)])209 s2 = Series([datetime(2001, 1, 1, 0, 0), datetime(2001, 1, 2, 0, 0),210 datetime(2001, 1, 3, 0, 0), 'foo', 1.0, 1,211 Timestamp('20010104'), '20010105'], dtype='O')212 result = s._convert(datetime=True)213 expected = Series([Timestamp('20010101'), Timestamp('20010102'),214 Timestamp('20010103')], dtype='M8[ns]')215 assert_series_equal(result, expected)216 result = s._convert(datetime=True, coerce=True)217 assert_series_equal(result, expected)218 expected = Series([Timestamp('20010101'), Timestamp('20010102'),219 Timestamp('20010103'), lib.NaT, lib.NaT, lib.NaT,220 Timestamp('20010104'), Timestamp('20010105')],221 dtype='M8[ns]')222 result = s2._convert(datetime=True, numeric=False, timedelta=False,223 coerce=True)224 assert_series_equal(result, expected)225 result = s2._convert(datetime=True, coerce=True)226 assert_series_equal(result, expected)227 s = Series(['foo', 'bar', 1, 1.0], dtype='O')228 result = s._convert(datetime=True, coerce=True)229 expected = Series([lib.NaT] * 2 + [Timestamp(1)] * 2)230 assert_series_equal(result, expected)231 # preserver if non-object232 s = Series([1], dtype='float32')233 result = s._convert(datetime=True, coerce=True)234 assert_series_equal(result, s)235 # r = s.copy()236 # r[0] = np.nan237 # result = r._convert(convert_dates=True,convert_numeric=False)238 # assert result.dtype == 'M8[ns]'239 # dateutil parses some single letters into today's value as a date240 expected = Series([lib.NaT])241 for x in 'abcdefghijklmnopqrstuvwxyz':242 s = Series([x])243 result = s._convert(datetime=True, coerce=True)244 assert_series_equal(result, expected)245 s = Series([x.upper()])246 result = s._convert(datetime=True, coerce=True)247 assert_series_equal(result, expected)248 def test_convert_no_arg_error(self):249 s = Series(['1.0', '2'])250 pytest.raises(ValueError, s._convert)251 def test_convert_preserve_bool(self):252 s = Series([1, True, 3, 5], dtype=object)253 r = s._convert(datetime=True, numeric=True)254 e = Series([1, 1, 3, 5], dtype='i8')255 tm.assert_series_equal(r, e)256 def test_convert_preserve_all_bool(self):257 s = Series([False, True, False, False], dtype=object)258 r = s._convert(datetime=True, numeric=True)259 e = Series([False, True, False, False], dtype=bool)...
basic.js
Source:basic.js
...106assert.deepEqual(convert["xyz"]["lab"](val), convert.xyz2lab(val));107val = [69, -48, 44];108assert.deepEqual(convert["lab"]["xyz"](val), [25, 39, 15]);109// converter110var converter = convert();111var vals = [140, 200, 100];112converter.rgb(140, 200, 100);113assert.deepEqual(converter.hsl(), convert.rgb2hsl(vals));114assert.deepEqual(converter.hsv(), convert.rgb2hsv(vals));115assert.deepEqual(converter.cmyk(), convert.rgb2cmyk(vals));116assert.deepEqual(converter.rgb(), vals);117assert.deepEqual(converter.rgb([255, 228, 196]).keyword(), "bisque");118vals = [96, 48, 59];119converter.hsl(vals);120assert.deepEqual(converter.rgb(), convert.hsl2rgb(vals));121assert.deepEqual(converter.hsv(), convert.hsl2hsv(vals));122assert.deepEqual(converter.cmyk(), convert.hsl2cmyk(vals));123assert.deepEqual(converter.keyword(), convert.hsl2keyword(vals));124// hwb...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!