github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/tools/phoneutil/phone_test.go (about)

     1  package phoneutil_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/ronaksoft/rony/tools/phoneutil"
     7  )
     8  
     9  /*
    10     Creation Time: 2021 - Jan - 01
    11     Created by:  (ehsan)
    12     Maintainers:
    13        1.  Ehsan N. Moosa (E2)
    14     Auditor: Ehsan N. Moosa (E2)
    15     Copyright Ronak Software Group 2020
    16  */
    17  
    18  func TestSanitizePhone(t *testing.T) {
    19  	phones := map[string]string{
    20  		"989121228718":   "989121228718",
    21  		"+989121228718":  "989121228718",
    22  		"9121228718":     "989121228718",
    23  		"00989121228718": "989121228718",
    24  	}
    25  
    26  	for ph, cph := range phones {
    27  		sph, err := phoneutil.SanitizePhone(ph, "IR")
    28  		if sph != cph || err != nil {
    29  			t.Fatal(err)
    30  		}
    31  	}
    32  
    33  	phones = map[string]string{
    34  		"989121228718":   "989121228718",
    35  		"+989121228718":  "989121228718",
    36  		"00989121228718": "989121228718",
    37  	}
    38  
    39  	for ph, cph := range phones {
    40  		sph, err := phoneutil.SanitizePhone(ph, "")
    41  		if sph != cph || err != nil {
    42  			t.Log(ph, "->", sph)
    43  			t.Fatal(err)
    44  		}
    45  	}
    46  }